Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Is there a way to send a key event programmatically?


If you are developing an SWT only app, I'm not sure.. perhaps an SWT person could help you.
If you are developing eclipse plugins, there are some services within eclipse to help you:

1. If your goal is to invoke a command itself, you are better off invoking the command directly using our API because key sequences can be re-assigned by the user. Ctrl-F7 might not do what you were expecting once the user customizes his key bindings.

The one-line version of this code reads as follows:
Workbench.getInstance().getCommandSupport().getCommandManager().getCommand("the.command.id").execute(null);

2. If you really want to inject a fake key stroke into our command processing mechanism, which effectively ends up calling the above method eventually anyway, we have a method to do this but I believe it it currently for internal use only. Also, it doesn't pass the key event through the widget hierarchy so you won't any menu items 'blink'. Please file an enhancement request to platform-ui-inbox@xxxxxxxxxxx if you would like this method made available to you.

Chris.




Yue MA <mayue@xxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

02/19/04 05:24 AM

Please respond to
platform-swt-dev

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] Is there a way to send a key event programmatically?





I want to invoke the accelerator menu (Ctrl+F7) programmatically in Eclipse. But I could not find a way to fire such keyEvent in code, Is there a mechanism in Eclipse can support this now? To simulate a key event? and will SWT support it in future? I think this kind of mechanism could make it possible to support the automation UI test of Eclipse.

Can I use notifyListeners(eventType, event)
to do that?

Need your help.


Ma Yue,
IBM Client Platform, IBM China Software Development Lab


Back to the top