Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Undo with keyboard
Undo with keyboard [message #158470] Thu, 18 November 2004 09:41 Go to next message
Eclipse User
Originally posted by: arnaud.knowesis.fr

I cannot undo in my gef editor with keyboard but I can delete

I create a keyHandler :

keyHandler = new KeyHandler();

keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;

keyHandler.put(KeyStroke.getPressed(26, SWT.CTRL),
getActionRegistry().getAction(ActionFactory.UNDO.getId()));

keyHandler.put(KeyStroke.getPressed(25, SWT.CTRL),
getActionRegistry().getAction(ActionFactory.REDO.getId()));


and I reference it in my configureGraphicalViewer method :

GraphicalViewerKeyHandler keyHandler=new
GraphicalViewerKeyHandler(getGraphicalViewer());
keyHandler.setParent(getCommonKeyHandler(getGraphicalViewer( )));
getGraphicalViewer().setKeyHandler(this.keyHandler);

It works fine with the delet command but doesn t seem to run with the
undo/redo

thx
Re: Undo with keyboard [message #158478 is a reply to message #158470] Thu, 18 November 2004 11:19 Go to previous messageGo to next message
Eclipse User
Originally posted by: none.us.ibm.com

I'm not sure if those are the correct keystrokes for undo. Have you put a
breakpoint in handleKeyPressed to see what the event actually is and if it
gets sent at all?

Undo/Redo are global actions with keybindings associated with the menu
entries. The menu entries might be intercepting the keystrokes (although
I've been told that this isn't the case if the action is disabled). Either
way, you'll want to register action handlers for those global actions since
that allows the user to use the menu as well. The same it true for delete.
KeyHandler is intended for stuff that doesn't appear in menus, although for
previous version of eclipse DELETE was not stolen by hte edit menu


"Arnaud" <arnaud@knowesis.fr> wrote in message
news:cnicai$pa8$1@www.eclipse.org...
> I cannot undo in my gef editor with keyboard but I can delete
>
> I create a keyHandler :
>
> keyHandler = new KeyHandler();
>
> keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(ActionFactory.DELETE.getId())) ;
>
> keyHandler.put(KeyStroke.getPressed(26, SWT.CTRL),
> getActionRegistry().getAction(ActionFactory.UNDO.getId()));
>
> keyHandler.put(KeyStroke.getPressed(25, SWT.CTRL),
> getActionRegistry().getAction(ActionFactory.REDO.getId()));
>
>
> and I reference it in my configureGraphicalViewer method :
>
> GraphicalViewerKeyHandler keyHandler=new
> GraphicalViewerKeyHandler(getGraphicalViewer());
> keyHandler.setParent(getCommonKeyHandler(getGraphicalViewer( )));
> getGraphicalViewer().setKeyHandler(this.keyHandler);
>
> It works fine with the delet command but doesn t seem to run with the
> undo/redo
>
> thx
Re: Undo with keyboard [message #159022 is a reply to message #158478] Mon, 22 November 2004 05:32 Go to previous messageGo to next message
Eclipse User
Originally posted by: arnaud.knowesis.fr

I tried some changes :
I don t bind CTRL + Z and DEL key with the KeyHandler
and I create an ActionBarContributor :

protected void buildActions() {

IWorkbenchAction
undo=ActionFactory.UNDO.create(getPage().getWorkbenchWindow( ));
addRetargetAction((RetargetAction) undo);

IWorkbenchAction
redo=ActionFactory.REDO.create(getPage().getWorkbenchWindow( ));
addRetargetAction((RetargetAction) redo);

IWorkbenchAction
delete=ActionFactory.DELETE.create(getPage().getWorkbenchWin dow());
addRetargetAction((RetargetAction) delete);
}


The actionDefinitionId is correctly set, (the key binding is correctly
shown in my Edit Menu) but the accelerator CTRL + Z or Del doesnt work...




Randy Hudson wrote:
> I'm not sure if those are the correct keystrokes for undo. Have you put a
> breakpoint in handleKeyPressed to see what the event actually is and if it
> gets sent at all?
>
> Undo/Redo are global actions with keybindings associated with the menu
> entries. The menu entries might be intercepting the keystrokes (although
> I've been told that this isn't the case if the action is disabled). Either
> way, you'll want to register action handlers for those global actions since
> that allows the user to use the menu as well. The same it true for delete.
> KeyHandler is intended for stuff that doesn't appear in menus, although for
> previous version of eclipse DELETE was not stolen by hte edit menu
>
Re: Undo with keyboard [message #159126 is a reply to message #159022] Mon, 22 November 2004 16:25 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik Shah
Messages: 1077
Registered: July 2009
Senior Member
Are you saying it works from the menu and not via the keyboard? I'm
assuming you've registered the ActionBarContributor properly in the
plugin.xml.

"Arnaud" <arnaud@knowesis.fr> wrote in message
news:cnsf79$c7m$1@www.eclipse.org...
> I tried some changes :
> I don t bind CTRL + Z and DEL key with the KeyHandler
> and I create an ActionBarContributor :
>
> protected void buildActions() {
>
> IWorkbenchAction
> undo=ActionFactory.UNDO.create(getPage().getWorkbenchWindow( ));
> addRetargetAction((RetargetAction) undo);
>
> IWorkbenchAction
> redo=ActionFactory.REDO.create(getPage().getWorkbenchWindow( ));
> addRetargetAction((RetargetAction) redo);
>
> IWorkbenchAction
> delete=ActionFactory.DELETE.create(getPage().getWorkbenchWin dow());
> addRetargetAction((RetargetAction) delete);
> }
>
>
> The actionDefinitionId is correctly set, (the key binding is correctly
> shown in my Edit Menu) but the accelerator CTRL + Z or Del doesnt work...
>
>
>
>
> Randy Hudson wrote:
> > I'm not sure if those are the correct keystrokes for undo. Have you put
a
> > breakpoint in handleKeyPressed to see what the event actually is and if
it
> > gets sent at all?
> >
> > Undo/Redo are global actions with keybindings associated with the menu
> > entries. The menu entries might be intercepting the keystrokes (although
> > I've been told that this isn't the case if the action is disabled).
Either
> > way, you'll want to register action handlers for those global actions
since
> > that allows the user to use the menu as well. The same it true for
delete.
> > KeyHandler is intended for stuff that doesn't appear in menus, although
for
> > previous version of eclipse DELETE was not stolen by hte edit menu
> >
Re: Undo with keyboard [message #159367 is a reply to message #159126] Thu, 25 November 2004 09:03 Go to previous message
Eclipse User
Originally posted by: arnaud.knowesis.fr

I found the problem ...

the undo action wasn t correctly registered in the workbenchadvisor class


Pratik Shah wrote:
> Are you saying it works from the menu and not via the keyboard? I'm
> assuming you've registered the ActionBarContributor properly in the
> plugin.xml.
>
> "Arnaud" <arnaud@knowesis.fr> wrote in message
> news:cnsf79$c7m$1@www.eclipse.org...
>
>>I tried some changes :
>>I don t bind CTRL + Z and DEL key with the KeyHandler
>>and I create an ActionBarContributor :
>>
>>protected void buildActions() {
>>
>> IWorkbenchAction
>> undo=ActionFactory.UNDO.create(getPage().getWorkbenchWindow( ));
>> addRetargetAction((RetargetAction) undo);
>>
>> IWorkbenchAction
>> redo=ActionFactory.REDO.create(getPage().getWorkbenchWindow( ));
>> addRetargetAction((RetargetAction) redo);
>>
>> IWorkbenchAction
>> delete=ActionFactory.DELETE.create(getPage().getWorkbenchWin dow());
>> addRetargetAction((RetargetAction) delete);
>> }
>>
>>
>>The actionDefinitionId is correctly set, (the key binding is correctly
>>shown in my Edit Menu) but the accelerator CTRL + Z or Del doesnt work...
>>
>>
>>
>>
>>Randy Hudson wrote:
>>
>>>I'm not sure if those are the correct keystrokes for undo. Have you put
>
> a
>
>>>breakpoint in handleKeyPressed to see what the event actually is and if
>
> it
>
>>>gets sent at all?
>>>
>>>Undo/Redo are global actions with keybindings associated with the menu
>>>entries. The menu entries might be intercepting the keystrokes (although
>>>I've been told that this isn't the case if the action is disabled).
>
> Either
>
>>>way, you'll want to register action handlers for those global actions
>
> since
>
>>>that allows the user to use the menu as well. The same it true for
>
> delete.
>
>>>KeyHandler is intended for stuff that doesn't appear in menus, although
>
> for
>
>>>previous version of eclipse DELETE was not stolen by hte edit menu
>>>
>
>
>
Previous Topic:FontPropertyDescriptor does not notify updates
Next Topic:Multi-level drawers in palette ?
Goto Forum:
  


Current Time: Thu Jul 24 02:37:39 EDT 2014

Powered by FUDForum. Page generated in 0.01899 seconds