Custom movement with arrow keys [message #658214] |
Mon, 07 March 2011 12:33 |
Kalin Nakov Messages: 6 Registered: October 2010 |
Junior Member |
|
|
Greetings,
I would like to implement some custom movement of border items (like UML
ports) with the arrow keys. The default GMF implementation uses the drag
tracker to simulate mouse dragging, which does not fit the product's
requirements. I want to move the border item with a single click of the
arrow keys with some predefined distance and force the border item locator
to snap it in the proper place. Here are the approaches I've tried
- Added a key listener to the draw2d figure with no success - the listener
is not called.
- Overrode DiagramEditor::configureGraphicalViewer() and used this code:
// register keyboard move actions
moveUpAction.setId(ACTION_ID_MOVE_UP);
getActionRegistry().registerAction(moveUpAction);
getSelectionActions().add(moveUpAction.getId());
getKeyHandler().put(KeyStroke.getPressed(SWT.ARROW_UP, 0), moveUpAction);
This code seems to be able to capture only keys like Enter by using
KeyStroke.getPressed(SWT.CR, '\r', 0). But it does not work with
SWT.ARROW_UP/DOWN/LEFT/RIGHT.
Thanks for the help in advance,
Kalin
|
|
|
Powered by
FUDForum. Page generated in 0.03263 seconds