Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Concepts/KeyStroke"

(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
Line 1: Line 1:
{{ScoutPage|cat=Component Model}}
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
 
+
Special type of {{ScoutLink|Concepts|Action|Action}} for key actions.
+
 
+
* implements: {{ScoutJavadoc|IKeyStroke|I}}
+
* extends: {{ScoutJavadoc|AbstractKeyStroke|C}}
+
 
+
== Description ==
+
In Eclipse Scout you can set KeyStrokes to components (such as Menus, Buttons, StringFields, GroupBoxes...). A KeyStroke represents a certain key sequence on the keyboard and can be associated with an action if the key sequence is pressed. For example one can associate a KeyStroke (F5) on a table in order to refresh it.
+
 
+
A KeyStroke in Scout is defined as a String and set via
+
<source lang="java">
+
@Override
+
protected String getConfiguredKeyStroke() {
+
  return "<keyStrokeDefinition>";
+
}
+
</source>
+
 
+
Below you will see some examples of keyStrokes:
+
 
+
* <tt>"Alt-F4"</tt> --> alternate-f4
+
* <tt>"Ctrl+Alt+1"</tt> --> control-alternate-1
+
* <tt>"F1"</tt> --> f1
+
* <tt>"F10"</tt> --> f10
+
* <tt>"Ctrl-Shift-1"</tt> --> control-shift-1
+
* <tt>"Ctrl-Shift-a"</tt> --> control-shift-a
+
 
+
If you want to map keys from the numeric keypad you need to use those keys identifiers in scout:
+
* <tt>"ADD"</tt> --> the "+" key in the numpad
+
* <tt>"SUBTRACT"</tt> --> the "-" key in the numpad
+
* <tt>"DIVIDE"</tt> -->  the "/" key in the numpad
+
* <tt>"MULTIPLY"</tt> --> the "*" key in the numpad
+
 
+
Scout defines predefined Strings which will be mapped to keyStrokes:
+
* alternate --> Alt
+
* control --> Ctrl
+
* f1 - f12 --> F1 - F12
+
* shift --> Shift
+
 
+
== Examples ==
+
=== KeyStroke on StringField ===
+
The following snippet shows a StringField with a keyStroke "F5", which will open a MessageBox if pressed:
+
 
+
<source lang="java">
+
public class StringField extends AbstractStringField {
+
 
+
  @Override
+
  protected String getConfiguredLabel() {
+
    return "StringField";
+
  }
+
 
+
  public class KeyStroke extends AbstractKeyStroke {
+
 
+
    @Override
+
    protected String getConfiguredKeyStroke() {
+
      return "f5";
+
    }
+
 
+
    @Override
+
    protected void execAction() throws ProcessingException {
+
      MessageBox.showOkMessage("KeyStroke", "F5 pressed on TextField", "");
+
    }
+
  }
+
}
+
</source>
+
 
+
=== KeyStroke on ContextMenu ===
+
The following snippet shows a SmartField with a context menu and a keyStroke "F5", which will open a MessageBox if pressed:
+
 
+
<source lang="java">
+
public class SmartFieldMenu extends AbstractExtensibleMenu {
+
 
+
  @Override
+
  protected void execAction() throws ProcessingException {
+
    MessageBox.showOkMessage("KeyStroke", "Alt+2 pressed on SmartField", "");
+
  }
+
 
+
  @Override
+
  protected String getConfiguredKeyStroke() {
+
    return "alt-2";
+
  }
+
 
+
  @Override
+
  protected String getConfiguredText() {
+
    return TEXTS.get("ContextMenu with KeyStroke");
+
    }
+
  }
+
}</source>
+
Will result in:
+
[[File:Keystroke_menu.png]]
+
 
+
== Screenshot ==
+
{{note|TODO|Add a screenshot (or remove this section, if there is no screenshot to make)}}
+
 
+
 
+
== Properties ==
+
''Defined with {{ScoutLink|Concepts|GetConfigured Methods|getConfiguredXxxxxx()}} methods''.
+
 
+
{{note|TODO|Add a description of important properties. The idea is not to recreate the JavaDoc of the getConfiguredXxxxxx() methods but to provide explanations, best practice, example... Group the properties by domain.}}
+
 
+
 
+
== Events ==
+
''Defined with {{ScoutLink|Concepts|Exec_Methods|execXxxxxx()}} methods''.
+
 
+
{{note|TODO|Add a description of important events. The idea is not to recreate the JavaDoc of the execXxxxxx() methods but to provide explanations, best practice, example... Group the events by domain.}}
+
 
+
 
+
== See Also ==
+
* {{ScoutLink|Concepts|Action|Action}}
+
* {{ScoutLink|Concepts|Client Plug-In|Client Plug-In}}
+

Latest revision as of 04:39, 14 March 2024

The Scout documentation has been moved to https://eclipsescout.github.io/.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.