diff options
author | Grant Gayed <ggayed> | 2010-03-04 16:35:02 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2010-03-04 16:35:02 +0000 |
commit | ee9b40960339cb073a160f4a991908b1b404f3db (patch) | |
tree | 89f4445c3f3041ac1f5dbc58a657f42e08aaa956 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java | |
parent | e86035e65ddb9883c55bfd1d1805aa43058a91c8 (diff) | |
download | eclipse.platform.swt-ee9b40960339cb073a160f4a991908b1b404f3db.tar.gz eclipse.platform.swt-ee9b40960339cb073a160f4a991908b1b404f3db.tar.xz eclipse.platform.swt-ee9b40960339cb073a160f4a991908b1b404f3db.zip |
303615 - Some traverse events in Browser are missing character, state mask and key code
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java')
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java | 184 |
1 files changed, 181 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index 267db9be54..5197726dbf 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -689,7 +689,7 @@ void destroyWidget () { * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise. * * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT when the event is null</li> + * <li>ERROR_NULL_ARGUMENT if the event is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> @@ -731,7 +731,7 @@ public boolean dragDetect (Event event) { * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise. * * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT when the event is null</li> + * <li>ERROR_NULL_ARGUMENT if the event is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> @@ -3692,7 +3692,8 @@ boolean traverse (Event event) { * traversal action. The argument should be one of the constants: * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, - * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>. + * <code>SWT.TRAVERSE_ARROW_NEXT</code>, <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>, + * <code>SWT.TRAVERSE_PAGE_NEXT</code> and <code>SWT.TRAVERSE_PAGE_PREVIOUS</code>. * * @param traversal the type of traversal * @return true if the traversal succeeded @@ -3710,6 +3711,183 @@ public boolean traverse (int traversal) { return traverse (event); } +/** + * Performs a platform traversal action corresponding to a <code>KeyDown</code> event. + * + * <p>Valid traversal values are + * <code>SWT.TRAVERSE_NONE</code>, <code>SWT.TRAVERSE_MNEMONIC</code>, + * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, + * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, + * <code>SWT.TRAVERSE_ARROW_NEXT</code>, <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>, + * <code>SWT.TRAVERSE_PAGE_NEXT</code> and <code>SWT.TRAVERSE_PAGE_PREVIOUS</code>. + * If <code>traversal</code> is <code>SWT.TRAVERSE_NONE</code> then the Traverse + * event is created with standard values based on the KeyDown event. If + * <code>traversal</code> is one of the other traversal constants then the Traverse + * event is created with this detail, and its <code>doit</code> is taken from the + * KeyDown event. + * </p> + * + * @param traversal the type of traversal, or <code>SWT.TRAVERSE_NONE</code> to compute + * this from <code>event</code> + * @param event the KeyDown event + * + * @return true if the traversal succeeded + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT if the event is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @since 3.6 + */ +public boolean traverse (int traversal, Event event) { + checkWidget (); + if (event == null) error (SWT.ERROR_NULL_ARGUMENT); + return traverse (traversal, event.character, event.keyCode, event.keyLocation, event.stateMask, event.doit); +} + +/** + * Performs a platform traversal action corresponding to a <code>KeyDown</code> event. + * + * <p>Valid traversal values are + * <code>SWT.TRAVERSE_NONE</code>, <code>SWT.TRAVERSE_MNEMONIC</code>, + * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, + * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, + * <code>SWT.TRAVERSE_ARROW_NEXT</code>, <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>, + * <code>SWT.TRAVERSE_PAGE_NEXT</code> and <code>SWT.TRAVERSE_PAGE_PREVIOUS</code>. + * If <code>traversal</code> is <code>SWT.TRAVERSE_NONE</code> then the Traverse + * event is created with standard values based on the KeyDown event. If + * <code>traversal</code> is one of the other traversal constants then the Traverse + * event is created with this detail, and its <code>doit</code> is taken from the + * KeyDown event. + * </p> + * + * @param traversal the type of traversal, or <code>SWT.TRAVERSE_NONE</code> to compute + * this from <code>event</code> + * @param event the KeyDown event + * + * @return true if the traversal succeeded + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT if the event is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @since 3.6 + */ +public boolean traverse (int traversal, KeyEvent event) { + checkWidget (); + if (event == null) error (SWT.ERROR_NULL_ARGUMENT); + return traverse (traversal, event.character, event.keyCode, event.keyLocation, event.stateMask, event.doit); +} + +boolean traverse (int traversal, char character, int keyCode, int keyLocation, int stateMask, boolean doit) { + if (traversal == SWT.TRAVERSE_NONE) { + switch (keyCode) { + case SWT.ESC: { + traversal = SWT.TRAVERSE_ESCAPE; + doit = true; + break; + } + case SWT.CR: { + traversal = SWT.TRAVERSE_RETURN; + doit = false; + break; + } + case SWT.ARROW_DOWN: + case SWT.ARROW_RIGHT: { + traversal = SWT.TRAVERSE_ARROW_NEXT; + doit = false; + break; + } + case SWT.ARROW_UP: + case SWT.ARROW_LEFT: { + traversal = SWT.TRAVERSE_ARROW_PREVIOUS; + doit = false; + break; + } + case SWT.TAB: { + traversal = (stateMask & SWT.SHIFT) != 0 ? SWT.TRAVERSE_TAB_PREVIOUS : SWT.TRAVERSE_TAB_NEXT; + doit = true; + break; + } + case SWT.PAGE_DOWN: { + if ((stateMask & SWT.CTRL) != 0) { + traversal = SWT.TRAVERSE_PAGE_NEXT; + doit = true; + } + break; + } + case SWT.PAGE_UP: { + if ((stateMask & SWT.CTRL) != 0) { + traversal = SWT.TRAVERSE_PAGE_PREVIOUS; + doit = true; + } + break; + } + default: { + if (character != 0 && (stateMask & (SWT.ALT | SWT.CTRL)) == SWT.ALT) { + traversal = SWT.TRAVERSE_MNEMONIC; + doit = true; + } + break; + } + } + } + + Event event = new Event (); + event.character = character; + event.detail = traversal; + event.doit = doit; + event.keyCode = keyCode; + event.keyLocation = keyLocation; + event.stateMask = stateMask; + + Shell shell = getShell (); + boolean all = false; + switch (traversal) { + case SWT.TRAVERSE_ESCAPE: + case SWT.TRAVERSE_RETURN: + case SWT.TRAVERSE_PAGE_NEXT: + case SWT.TRAVERSE_PAGE_PREVIOUS: { + all = true; + // FALL THROUGH + } + case SWT.TRAVERSE_ARROW_NEXT: + case SWT.TRAVERSE_ARROW_PREVIOUS: + case SWT.TRAVERSE_TAB_NEXT: + case SWT.TRAVERSE_TAB_PREVIOUS: { + /* traversal is a valid traversal action */ + break; + } + case SWT.TRAVERSE_MNEMONIC: { + return translateMnemonic (event, null) || shell.translateMnemonic (event, this); + } + default: { + /* traversal is not a valid traversal action */ + return false; + } + } + + Control control = this; + do { + if (control.traverse (event)) { + OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0); + return true; + } + if (!event.doit && control.hooks (SWT.Traverse)) return false; + if (control == shell) return false; + control = control.parent; + } while (all && control != null); + return false; +} + boolean traverseEscape () { return false; } |