pressShortcut() problem with Keystrokes.MOD2 [message #487776] |
Thu, 24 September 2009 12:00 |
Andrii Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Hi,
i have the problem with sending shortcuts to widgets.
Then i use
keyboard().pressShortcut(Keystrokes.MOD3, Keystrokes.MOD1, Keystrokes.DOWN); to press shortcut, my widget receive the events
Quote: |
Key pressed: KeyEvent{McGrid {} time=624807531 data=null character='\0' keyCode=65536 stateMask=0 doit=true}
Key pressed: KeyEvent{McGrid {} time=624807531 data=null character='\0' keyCode=262144 stateMask=65536 doit=true}
Key pressed: KeyEvent{McGrid {} time=624807531 data=null character='\0' keyCode=16777218 stateMask=327680 doit=true}
....
release keys here
|
and this is correct, but when i use
in my shortcuts, calling keyboard().pressShortcut(Keystrokes.MOD2, Keystrokes.MOD1, Keystrokes.DOWN); ,
events are
Quote: |
Key pressed: KeyEvent{McGrid {} time=625248750 data=null character='\0' keyCode=131072 stateMask=0 doit=true}
Key pressed: KeyEvent{McGrid {} time=625248750 data=null character='\0' keyCode=262144 stateMask=131072 doit=true}
Key pressed: KeyEvent{McGrid {} time=625248750 data=null character='\0' keyCode=16777218 stateMask=262144 doit=true}
Key pressed: KeyEvent{McGrid {} time=625248750 data=null character='\0' keyCode=131072 stateMask=262144 doit=true}
....
release keys here
|
What i am doing wrong? How i can press CTRL+SHIFT+ARROW_DOWN shortcut ?
|
|
|
Re: pressShortcut() problem with Keystrokes.MOD2 [message #487850 is a reply to message #487776] |
Thu, 24 September 2009 14:50 |
Andrii Messages: 3 Registered: July 2009 |
Junior Member |
|
|
I try to use org.eclipse.swtbot.swt.finder.keyboard.SWTKeyboardStrategy and org.eclipse.swtbot.swt.finder.keyboard.MockKeyboardStrategy
with no result, parsing Keystrokes.SHIFT seems to be incorrect
But I can handle this by sending event directly using
AbstractSWTBot.notify(final int eventType, final Event createEvent, final Widget widget)
so this works for me,
notifyKeyboardEvent(SWT.MOD1|SWT.MOD2, '\0', SWT.ARROW_DOWN);
where
protected Event keyEvent(final int modificationKey, final char c, final int keyCode) {
final Event keyEvent = createEvent();
keyEvent.stateMask = modificationKey;
keyEvent.character = c;
keyEvent.keyCode = keyCode;
return keyEvent;
}
....
public void notifyKeyboardEvent(final int modificationKey, final char c, final int keyCode) {
....
notify(SWT.KeyDown, keyEvent(modificationKey, c, keyCode));
....
}
but as i see MockKeyboardStrategy do exaclty the same but unfortunatelly send strange event sequence.....
|
|
|
Re: pressShortcut() problem with Keystrokes.MOD2 [message #487960 is a reply to message #487850] |
Fri, 25 September 2009 05:03 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
Hi Andrii,
I just looked at the keyboard constants defined in the Keystrokes class,
and the corresponding constants in the swt class.
MOD1 and MOD2 keys are defined as CTRL and SHIFT respectively, so I'm
unsure why that does not work -- Please file a bug with a link to this
conversation and I'll take a look at it.
Regarding the mock strategy -- this is to be used only as a last resort.
This strategy has its own quirks and does not work when there are verify
listeners hooked in etc. Use sparingly with caution.
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
On 24/09/09 8:20 PM, Andrii wrote:
> I try to use org.eclipse.swtbot.swt.finder.keyboard.SWTKeyboardStrategy
> and org.eclipse.swtbot.swt.finder.keyboard.MockKeyboardStrategy
> with no result, parsing Keystrokes.SHIFT seems to be incorrect
>
> But I can handle this by sending event directly using
> AbstractSWTBot.notify(final int eventType, final Event createEvent,
> final Widget widget)
>
> so this works for me,
> notifyKeyboardEvent(SWT.MOD1|SWT.MOD2, '\0', SWT.ARROW_DOWN);
>
>
> where
> protected Event keyEvent(final int modificationKey, final char c, final
> int keyCode) {
> final Event keyEvent = createEvent();
> keyEvent.stateMask = modificationKey;
> keyEvent.character = c;
> keyEvent.keyCode = keyCode;
> return keyEvent;
> }
>
> ....
> public void notifyKeyboardEvent(final int modificationKey, final char c,
> final int keyCode) {
> ....
> notify(SWT.KeyDown, keyEvent(modificationKey, c, keyCode));
> ....
> }
>
>
> but as i see MockKeyboardStrategy do exaclty the same but unfortunatelly
> send strange event sequence.....
>
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03054 seconds