diff options
author | Marc Englund <marc.englund@itmill.com> | 2010-04-09 08:45:41 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2010-04-09 08:45:41 +0000 |
commit | d3b01e81254ae0da3028820524abba23866f7f7d (patch) | |
tree | cf443230e5a69a4c0053964d3d3ddc9a1dbc8258 /src/com/vaadin/ui/Button.java | |
parent | a1b0c194b7c7b220e594a6b1c50d432de42abef1 (diff) | |
download | vaadin-framework-d3b01e81254ae0da3028820524abba23866f7f7d.tar.gz vaadin-framework-d3b01e81254ae0da3028820524abba23866f7f7d.zip |
Javadocced shortcuts
svn changeset:12421/svn branch:6.3
Diffstat (limited to 'src/com/vaadin/ui/Button.java')
-rw-r--r-- | src/com/vaadin/ui/Button.java | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 038186ce16..2a38348105 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -10,12 +10,15 @@ import java.lang.reflect.Method; import java.util.Map; import com.vaadin.data.Property; -import com.vaadin.event.ShortcutListener; import com.vaadin.event.FieldEvents; +import com.vaadin.event.ShortcutAction; +import com.vaadin.event.ShortcutListener; import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.event.ShortcutAction.KeyCode; +import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.VButton; @@ -379,23 +382,36 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); } - + /* * Actions */ protected ClickShortcut clickShortcut; - public ClickShortcut setClickShortcut(int keyCode, int... modifiers) { - ClickShortcut old = clickShortcut; - if (old != null) { - removeShortcutListener(old); + /** + * Makes it possible to invoke a click on this button by pressing the given + * {@link KeyCode} and (optional) {@link ModifierKey}s.<br/> + * The shortcut is global (bound to the containing Window). + * + * @param keyCode + * the keycode for invoking the shortcut + * @param modifiers + * the (optional) modifiers for invoking the shortcut, null for + * none + */ + public void setClickShortcut(int keyCode, int... modifiers) { + if (clickShortcut != null) { + removeShortcutListener(clickShortcut); } clickShortcut = new ClickShortcut(this, keyCode, modifiers); addShortcutListener(clickShortcut); - return old; } + /** + * Removes the keyboard shortcut previously set with + * {@link #setClickShortcut(int, int...)}. + */ public void removeClickShortcut() { if (clickShortcut != null) { removeShortcutListener(clickShortcut); @@ -403,19 +419,53 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, } } + /** + * A {@link ShortcutListener} specifically made to define a keyboard + * shortcut that invokes a click on the given button. + * + */ public static class ClickShortcut extends ShortcutListener { protected Button button; + /** + * Creates a keyboard shortcut for clicking the given button using the + * shorthand notation defined in {@link ShortcutAction}. + * + * @param button + * to be clicked when the shortcut is invoked + * @param shorthandCaption + * the caption with shortcut keycode and modifiers indicated + */ public ClickShortcut(Button button, String shorthandCaption) { super(shorthandCaption); this.button = button; } + /** + * Creates a keyboard shortcut for clicking the given button using the + * given {@link KeyCode} and {@link ModifierKey}s. + * + * @param button + * to be clicked when the shortcut is invoked + * @param keyCode + * KeyCode to react to + * @param modifiers + * optional modifiers for shortcut + */ public ClickShortcut(Button button, int keyCode, int... modifiers) { super(null, keyCode, modifiers); this.button = button; } + /** + * Creates a keyboard shortcut for clicking the given button using the + * given {@link KeyCode}. + * + * @param button + * to be clicked when the shortcut is invoked + * @param keyCode + * KeyCode to react to + */ public ClickShortcut(Button button, int keyCode) { this(button, keyCode, null); } |