Home » Eclipse Projects » GEF » Problems with GEF KeyStrokes
Problems with GEF KeyStrokes [message #212953] |
Fri, 31 March 2006 11:56 |
Eclipse User |
|
|
|
Originally posted by: dutz.c-ware.de
Hi,
I am having some strange problems with gef keystrokes. (hiting delete-key
deletes the currently selected editpart)
keyHandler.put(KeyStroke.getPressed('\177', 127, 0),
getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
works fine ... even if I use this for testing (hiting delete-key selects all
editparts)
keyHandler.put(KeyStroke.getPressed('\177', 127, 0),
getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId ()));
SelectAll is executed without any problems. (hiting CTRL+F4 selects all
editparts)
keyHandler.put(KeyStroke.getPressed(SWT.F4, SWT.CTRL),
getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId ()));
Also works fine .... but not
keyHandler.put(KeyStroke.getPressed('a', SWT.CTRL),
getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId ()));
or
keyHandler.put(KeyStroke.getPressed('\141', SWT.CTRL),
getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId ()));
And I have absolutely no idea why. I just want to bint the "CTRL+A" key to
my action.
Any help is greatly appreciated.
Chris
|
|
|
Re: Problems with GEF KeyStrokes [message #213111 is a reply to message #212953] |
Mon, 03 April 2006 10:00 |
Eclipse User |
|
|
|
Originally posted by: lesliesoftware.yahoo.com
I recently faced just about the same thing. While I found that hooking up
the F2 key was easy:
// Hook the F2 key to the direct edit action
mySharedKeyHandler.put (KeyStroke.getPressed (SWT.F2, 0),
getActionRegistry ().getAction
(GEFActionConstants.DIRECT_EDIT));
worked great, getting things hooked up to other chracters did not work:
mySharedKeyHandler.put (KeyStroke.getPressed ('+', 0),
getActionRegistry ().getAction
(IncrementDecrementAction.INCREMENT_ID));
I found a handy SWT snippet that saved the day:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet25. java
If you create your KeyStroke objects using the values from that snippet
things work:
mySharedKeyHandler.put (KeyStroke.getPressed ('+', 0x3d, SWT.SHIFT),
getActionRegistry ().getAction
(IncrementDecrementAction.INCREMENT_ID));
So for your case you want CTRL+A: run the snippet and press they key then
use the three parameter getPressed method (getPressed(char character, int
keyCode, int stateMask)) with the parameters from snippet 25 thus:
keyHandler.put(KeyStroke.getPressed('a', 0x1, SWT.CTRL),
getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId ()));
It worked for me.
Ian
|
|
|
Re: Problems with GEF KeyStrokes [message #214387 is a reply to message #213111] |
Mon, 17 April 2006 12:37 |
Eclipse User |
|
|
|
Originally posted by: dutz.c-ware.de
Just tried that ... unfortualtely this didn't work. Just as I expected,
becaue I can remember having tried that ... I'll bet its that pescy
MultipageEditor runining my efforts ... wouldn't be the first time.
No problem, ist one of the 1000 things I simply quit working on since it
seems to be hell of a problem with eclipse.
Tanks anyway
"Ian Leslie" <lesliesoftware@yahoo.com> schrieb im Newsbeitrag
news:0d78036d772d31f39d365c893ef581a1$1@www.eclipse.org...
>I recently faced just about the same thing. While I found that hooking up
>the F2 key was easy:
> // Hook the F2 key to the direct edit action
> mySharedKeyHandler.put (KeyStroke.getPressed (SWT.F2, 0),
> getActionRegistry ().getAction (GEFActionConstants.DIRECT_EDIT));
>
> worked great, getting things hooked up to other chracters did not work:
> mySharedKeyHandler.put (KeyStroke.getPressed ('+', 0),
> getActionRegistry ().getAction
> (IncrementDecrementAction.INCREMENT_ID));
>
> I found a handy SWT snippet that saved the day:
> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet25. java
>
> If you create your KeyStroke objects using the values from that snippet
> things work:
> mySharedKeyHandler.put (KeyStroke.getPressed ('+', 0x3d, SWT.SHIFT),
> getActionRegistry ().getAction
> (IncrementDecrementAction.INCREMENT_ID));
>
> So for your case you want CTRL+A: run the snippet and press they key then
> use the three parameter getPressed method (getPressed(char character, int
> keyCode, int stateMask)) with the parameters from snippet 25 thus:
> keyHandler.put(KeyStroke.getPressed('a', 0x1, SWT.CTRL),
>
> getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId ()));
>
> It worked for me.
>
> Ian
>
>
|
|
|
Goto Forum:
Current Time: Thu Jan 23 12:01:13 GMT 2025
Powered by FUDForum. Page generated in 0.03058 seconds
|