Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » WorbenchWindow KeyListener
WorbenchWindow KeyListener [message #447618] Wed, 12 April 2006 04:24 Go to next message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Hi,all:
I want to let the WorkbenchWindow respond to key press,then how to
register keylistener to WorkbenchWindow?

Regards,
Karl.
Re: WorbenchWindow KeyListener [message #447675 is a reply to message #447618] Wed, 12 April 2006 11:59 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The workbench window already responds to key presses ... so I'm guessing
that's not your question :-)

If you want to attach a command or action to a key combination, that's
key binding, and you use the org.eclipse.ui.bindings extension point.
IIRC, there's also a programmatic part to that interface.

Within an editor or view you can attach key listeners to widgets like
StyledText? Do you mean that?


But really, what are you trying to do? What effect do you want to
present to the user?

Later,
PW


Re: WorbenchWindow KeyListener [message #447695 is a reply to message #447675] Thu, 13 April 2006 01:21 Go to previous messageGo to next message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Thanks for your help.:-)
Oh, at first, I think workbench window can respond to key event only
through key bindings which is assoicated with an action contribution, but
i don't want to use action contribution because it's visible and i need
hidden keys respond to user.These hidden keys respond execute some system
administration functions like lock, unlock etc.This is the cause why i ask
workbench window key listener.
Workkbench window key event is wrappered by jface action mechanism,so we
can't use addKeyListener to it directly,isn't it?
I saw a link you give in some
post:http://www.magma.ca/~pollockd/despumate/bindingsHowTo.h tml and get
some hints from the following statements:
IKeyBindingService service = site.getKeyBindingService();
yourAction.setActionDefinitionId("existingCommandId");
service.registerAction(yourAction);
then in order to get hidden key respond function, I can define an action
class and register it in runtime and it can do the same thing with action
contribution, is it right?

Regards,
Karl.
Re: WorbenchWindow KeyListener [message #447696 is a reply to message #447695] Thu, 13 April 2006 01:26 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Is this your usecase: You want actions available, with keybindings, but
not in the menu and not in the toolbar?


You can always use the command / handler / binding extension points.

Create your command, "lock"
Create a handler (execution code) for "lock"
Create a binding to bind the command "lock" to some keys.

Later,
PW


Re: WorbenchWindow KeyListener [message #447697 is a reply to message #447696] Thu, 13 April 2006 09:35 Go to previous messageGo to next message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Hi,
Thanks for your help.:-)
Is there any other way that does not use extensions,because I don't want
these informations to be displayed in plugin.xml which is clear text
format.

Regards,
Karl.
Re: WorbenchWindow KeyListener [message #447700 is a reply to message #447697] Thu, 13 April 2006 11:23 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Any supported way? No.

You could try display.addFilter(*) to capture your key events ... but
I'm not sure what the side effects would be, and I'm not sure what order
the display filters are added in.

You can check out WorkbenchKeyboard to see how the workbench turns key
presses into commands.

final Listener listener = keyboard.getKeyDownFilter();
display.addFilter(SWT.KeyDown, listener);
display.addFilter(SWT.Traverse, listener);

Later,
PW


Re: WorbenchWindow KeyListener [message #447701 is a reply to message #447700] Thu, 13 April 2006 12:04 Go to previous message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Thanks for your help.:-)
Previous Topic:window.getSelectionService().getSelection() returns NULL
Next Topic:Problem View
Goto Forum:
  


Current Time: Thu Dec 26 12:50:00 GMT 2024

Powered by FUDForum. Page generated in 1.03257 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top