Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Keyboard shortcuts
Keyboard shortcuts [message #203290] Mon, 21 November 2005 16:22 Go to next message
Eclipse UserFriend
Originally posted by: radicr.stop.spam.gmail.com

Hello,

I would like to know how can i enable users to use CTRL+Z combination for
undo actions. I tried everything - but i cant get it to work
I am using RCP, and maybe this is the problem. I even transferred Logic
example from plugin to a RCP application, from plugin CTRL+Z works, but from
RCP it doesnt. Maybe problem is in RCP?

I have another RCP editor, and i dont know where in code i need to "turn on"
keyboard shortcut for undo. I have EditorActionBarContributor and

protected void buildActions() {
addRetargetAction(new UndoRetargetAction());
}

public void contributeToToolBar(IToolBarManager toolBarManager) {
toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
}

public void contributeToMenu(IMenuManager manager) {
MenuManager editMenu = new MenuManager("&Edit",
IWorkbenchActionConstants.M_FILE);
manager.add(editMenu);
editMenu.add(getAction(ActionFactory.UNDO.getId()));
}

protected void declareGlobalActionKeys() {
addGlobalActionKey(ActionFactory.UNDO.getId());
}
....
in EditorPage:

protected KeyHandler getCommonKeyHandler() {
if (sharedKeyHandler == null) {
sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
getMultipageBuildingEditor().getActionRegistry().getAction(
ActionFactory.UNDO.getId()));
}
return sharedKeyHandler;
}
....
in MultiPageEditorPart

protected void createActions(IEditorSite site) {
addStackAction(new UndoAction(this));

ActionRegistry registry = getActionRegistry();
IActionBars bars = site.getActionBars();
String id = ActionFactory.UNDO.getId();
bars.setGlobalActionHandler(id, registry.getAction(id));
getSite().getKeyBindingService().registerAction(registry.get Action(id));
....

But i cant do undo with CTRL+Z. Where is the proper place to do it?

--
Pozdrav,
Radovan
Re: Keyboard shortcuts [message #203300 is a reply to message #203290] Mon, 21 November 2005 16:58 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I just do the same thing as in GraphicalEditor.createActions() and have no
problems.
In configureGraphicalViewer() I also have this:
KeyHandler keyHandler = new GraphicalViewerKeyHandler( viewer );
viewer.setKeyHandler( keyHandler );


But your code in getCommonKeyHandler() looks strange.

"Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
news:dlssaq$ku5$1@news.eclipse.org...
> Hello,
>
> I would like to know how can i enable users to use CTRL+Z combination for
> undo actions. I tried everything - but i cant get it to work
> I am using RCP, and maybe this is the problem. I even transferred Logic
> example from plugin to a RCP application, from plugin CTRL+Z works, but
> from
> RCP it doesnt. Maybe problem is in RCP?
>
> I have another RCP editor, and i dont know where in code i need to "turn
> on"
> keyboard shortcut for undo. I have EditorActionBarContributor and
>
> protected void buildActions() {
> addRetargetAction(new UndoRetargetAction());
> }
>
> public void contributeToToolBar(IToolBarManager toolBarManager) {
> toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
> }
>
> public void contributeToMenu(IMenuManager manager) {
> MenuManager editMenu = new MenuManager("&Edit",
> IWorkbenchActionConstants.M_FILE);
> manager.add(editMenu);
> editMenu.add(getAction(ActionFactory.UNDO.getId()));
> }
>
> protected void declareGlobalActionKeys() {
> addGlobalActionKey(ActionFactory.UNDO.getId());
> }
> ...
> in EditorPage:
>
> protected KeyHandler getCommonKeyHandler() {
> if (sharedKeyHandler == null) {
> sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
> getMultipageBuildingEditor().getActionRegistry().getAction(
> ActionFactory.UNDO.getId()));
> }
> return sharedKeyHandler;
> }
> ...
> in MultiPageEditorPart
>
> protected void createActions(IEditorSite site) {
> addStackAction(new UndoAction(this));
>
> ActionRegistry registry = getActionRegistry();
> IActionBars bars = site.getActionBars();
> String id = ActionFactory.UNDO.getId();
> bars.setGlobalActionHandler(id, registry.getAction(id));
> getSite().getKeyBindingService().registerAction(registry.get Action(id));
> ...
>
> But i cant do undo with CTRL+Z. Where is the proper place to do it?
>
> --
> Pozdrav,
> Radovan
>
>
Re: Keyboard shortcuts [message #203353 is a reply to message #203290] Mon, 21 November 2005 19:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

MultiPageEditorParts have several known issues. Search this newsgroup for
that topic.

"Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
news:dlssaq$ku5$1@news.eclipse.org...
> Hello,
>
> I would like to know how can i enable users to use CTRL+Z combination for
> undo actions. I tried everything - but i cant get it to work
> I am using RCP, and maybe this is the problem. I even transferred Logic
> example from plugin to a RCP application, from plugin CTRL+Z works, but
from
> RCP it doesnt. Maybe problem is in RCP?
>
> I have another RCP editor, and i dont know where in code i need to "turn
on"
> keyboard shortcut for undo. I have EditorActionBarContributor and
>
> protected void buildActions() {
> addRetargetAction(new UndoRetargetAction());
> }
>
> public void contributeToToolBar(IToolBarManager toolBarManager) {
> toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
> }
>
> public void contributeToMenu(IMenuManager manager) {
> MenuManager editMenu = new MenuManager("&Edit",
> IWorkbenchActionConstants.M_FILE);
> manager.add(editMenu);
> editMenu.add(getAction(ActionFactory.UNDO.getId()));
> }
>
> protected void declareGlobalActionKeys() {
> addGlobalActionKey(ActionFactory.UNDO.getId());
> }
> ...
> in EditorPage:
>
> protected KeyHandler getCommonKeyHandler() {
> if (sharedKeyHandler == null) {
> sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
> getMultipageBuildingEditor().getActionRegistry().getAction(
> ActionFactory.UNDO.getId()));
> }
> return sharedKeyHandler;
> }
> ...
> in MultiPageEditorPart
>
> protected void createActions(IEditorSite site) {
> addStackAction(new UndoAction(this));
>
> ActionRegistry registry = getActionRegistry();
> IActionBars bars = site.getActionBars();
> String id = ActionFactory.UNDO.getId();
> bars.setGlobalActionHandler(id, registry.getAction(id));
> getSite().getKeyBindingService().registerAction(registry.get Action(id));
> ...
>
> But i cant do undo with CTRL+Z. Where is the proper place to do it?
>
> --
> Pozdrav,
> Radovan
>
>
Re: Keyboard shortcuts [message #203434 is a reply to message #203300] Tue, 22 November 2005 08:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: radicr.stop.spam.gmail.com

Thanks Felix,

I use this

private void createGraphicalViewer(Composite parent) {
viewer = new ScrollingGraphicalViewer();
viewer.createControl(parent);
viewer.getControl().setBackground(parent.getBackground());
viewer.setRootEditPart(new ScalableRootEditPart());
viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
.setParent(getCommonKeyHandler()));
...
}

And this is why i use getCommonKeyHandler()
I tried your code as well, but it doesnt work the same.

"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:dlsub0$nt5$1@news.eclipse.org...
> I just do the same thing as in GraphicalEditor.createActions() and have no
> problems.
> In configureGraphicalViewer() I also have this:
> KeyHandler keyHandler = new GraphicalViewerKeyHandler( viewer );
> viewer.setKeyHandler( keyHandler );
>
>
> But your code in getCommonKeyHandler() looks strange.
>
> "Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
> news:dlssaq$ku5$1@news.eclipse.org...
> > Hello,
> >
> > I would like to know how can i enable users to use CTRL+Z combination
for
> > undo actions. I tried everything - but i cant get it to work
> > I am using RCP, and maybe this is the problem. I even transferred Logic
> > example from plugin to a RCP application, from plugin CTRL+Z works, but
> > from
> > RCP it doesnt. Maybe problem is in RCP?
> >
> > I have another RCP editor, and i dont know where in code i need to "turn
> > on"
> > keyboard shortcut for undo. I have EditorActionBarContributor and
> >
> > protected void buildActions() {
> > addRetargetAction(new UndoRetargetAction());
> > }
> >
> > public void contributeToToolBar(IToolBarManager toolBarManager) {
> > toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
> > }
> >
> > public void contributeToMenu(IMenuManager manager) {
> > MenuManager editMenu = new MenuManager("&Edit",
> > IWorkbenchActionConstants.M_FILE);
> > manager.add(editMenu);
> > editMenu.add(getAction(ActionFactory.UNDO.getId()));
> > }
> >
> > protected void declareGlobalActionKeys() {
> > addGlobalActionKey(ActionFactory.UNDO.getId());
> > }
> > ...
> > in EditorPage:
> >
> > protected KeyHandler getCommonKeyHandler() {
> > if (sharedKeyHandler == null) {
> > sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
> > getMultipageBuildingEditor().getActionRegistry().getAction(
> > ActionFactory.UNDO.getId()));
> > }
> > return sharedKeyHandler;
> > }
> > ...
> > in MultiPageEditorPart
> >
> > protected void createActions(IEditorSite site) {
> > addStackAction(new UndoAction(this));
> >
> > ActionRegistry registry = getActionRegistry();
> > IActionBars bars = site.getActionBars();
> > String id = ActionFactory.UNDO.getId();
> > bars.setGlobalActionHandler(id, registry.getAction(id));
> >
getSite().getKeyBindingService().registerAction(registry.get Action(id));
> > ...
> >
> > But i cant do undo with CTRL+Z. Where is the proper place to do it?
> >
> > --
> > Pozdrav,
> > Radovan
> >
> >
>
>
Re: Keyboard shortcuts [message #203564 is a reply to message #203434] Tue, 22 November 2005 20:36 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
What I thought looked strange in getCommonKeyHandler() is

if (sharedKeyHandler == null) {
sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0)

i.e. you are putting something into the null sharedKeyHandler.

Anyway, I don't need to add any keystrokes for the UndoAction because it is
a retarget action. My ActionBarContributor.buildActions() looks like this:

protected void buildActions() {
addRetargetAction( new UndoRetargetAction() );
...
}

and is specified as the contributorClass for my editor in plugin.xml.


"Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
news:dlulhe$u0k$1@news.eclipse.org...
> Thanks Felix,
>
> I use this
>
> private void createGraphicalViewer(Composite parent) {
> viewer = new ScrollingGraphicalViewer();
> viewer.createControl(parent);
> viewer.getControl().setBackground(parent.getBackground());
> viewer.setRootEditPart(new ScalableRootEditPart());
> viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
> .setParent(getCommonKeyHandler()));
> ...
> }
>
> And this is why i use getCommonKeyHandler()
> I tried your code as well, but it doesnt work the same.
>
> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> news:dlsub0$nt5$1@news.eclipse.org...
>> I just do the same thing as in GraphicalEditor.createActions() and have
>> no
>> problems.
>> In configureGraphicalViewer() I also have this:
>> KeyHandler keyHandler = new GraphicalViewerKeyHandler( viewer );
>> viewer.setKeyHandler( keyHandler );
>>
>>
>> But your code in getCommonKeyHandler() looks strange.
>>
>> "Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
>> news:dlssaq$ku5$1@news.eclipse.org...
>> > Hello,
>> >
>> > I would like to know how can i enable users to use CTRL+Z combination
> for
>> > undo actions. I tried everything - but i cant get it to work
>> > I am using RCP, and maybe this is the problem. I even transferred Logic
>> > example from plugin to a RCP application, from plugin CTRL+Z works, but
>> > from
>> > RCP it doesnt. Maybe problem is in RCP?
>> >
>> > I have another RCP editor, and i dont know where in code i need to
>> > "turn
>> > on"
>> > keyboard shortcut for undo. I have EditorActionBarContributor and
>> >
>> > protected void buildActions() {
>> > addRetargetAction(new UndoRetargetAction());
>> > }
>> >
>> > public void contributeToToolBar(IToolBarManager toolBarManager) {
>> > toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
>> > }
>> >
>> > public void contributeToMenu(IMenuManager manager) {
>> > MenuManager editMenu = new MenuManager("&Edit",
>> > IWorkbenchActionConstants.M_FILE);
>> > manager.add(editMenu);
>> > editMenu.add(getAction(ActionFactory.UNDO.getId()));
>> > }
>> >
>> > protected void declareGlobalActionKeys() {
>> > addGlobalActionKey(ActionFactory.UNDO.getId());
>> > }
>> > ...
>> > in EditorPage:
>> >
>> > protected KeyHandler getCommonKeyHandler() {
>> > if (sharedKeyHandler == null) {
>> > sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
>> > getMultipageBuildingEditor().getActionRegistry().getAction(
>> > ActionFactory.UNDO.getId()));
>> > }
>> > return sharedKeyHandler;
>> > }
>> > ...
>> > in MultiPageEditorPart
>> >
>> > protected void createActions(IEditorSite site) {
>> > addStackAction(new UndoAction(this));
>> >
>> > ActionRegistry registry = getActionRegistry();
>> > IActionBars bars = site.getActionBars();
>> > String id = ActionFactory.UNDO.getId();
>> > bars.setGlobalActionHandler(id, registry.getAction(id));
>> >
> getSite().getKeyBindingService().registerAction(registry.get Action(id));
>> > ...
>> >
>> > But i cant do undo with CTRL+Z. Where is the proper place to do it?
>> >
>> > --
>> > Pozdrav,
>> > Radovan
>> >
>> >
>>
>>
>
>
Re: Keyboard shortcuts [message #203622 is a reply to message #203564] Wed, 23 November 2005 10:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: radicr.stop.spam.gmail.com

I forgot that i reduced code
there are more lines in this method

sharedKeyHandler = new KeyHandler();
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
getMultipageBuildingEditor().getActionRegistry().getAction(
ActionFactory.DELETE.getId()));
....
and with this SWT.DEL - delete key from keyboard works, but CTRL+Z with

sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
getMultipageBuildingEditor().getActionRegistry().getAction(
ActionFactory.UNDO.getId()));

doesnt work.

I have contributor in plugin.xml as well, but it still doesnt work.
Thank you all for your help, but i am having a lot of problems with eclipse.
Main problem is that i didnt manage to get some extensive instructions about
this matter, so i am only guessing and trying to use magic in order for my
keyboard actions work in gef.

"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:dlvvgg$qm$1@news.eclipse.org...
> What I thought looked strange in getCommonKeyHandler() is
>
> if (sharedKeyHandler == null) {
> sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0)
>
> i.e. you are putting something into the null sharedKeyHandler.
>
> Anyway, I don't need to add any keystrokes for the UndoAction because it
is
> a retarget action. My ActionBarContributor.buildActions() looks like this:
>
> protected void buildActions() {
> addRetargetAction( new UndoRetargetAction() );
> ...
> }
>
> and is specified as the contributorClass for my editor in plugin.xml.
>
>
> "Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
> news:dlulhe$u0k$1@news.eclipse.org...
> > Thanks Felix,
> >
> > I use this
> >
> > private void createGraphicalViewer(Composite parent) {
> > viewer = new ScrollingGraphicalViewer();
> > viewer.createControl(parent);
> > viewer.getControl().setBackground(parent.getBackground());
> > viewer.setRootEditPart(new ScalableRootEditPart());
> > viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
> > .setParent(getCommonKeyHandler()));
> > ...
> > }
> >
> > And this is why i use getCommonKeyHandler()
> > I tried your code as well, but it doesnt work the same.
> >
> > "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> > news:dlsub0$nt5$1@news.eclipse.org...
> >> I just do the same thing as in GraphicalEditor.createActions() and have
> >> no
> >> problems.
> >> In configureGraphicalViewer() I also have this:
> >> KeyHandler keyHandler = new GraphicalViewerKeyHandler( viewer );
> >> viewer.setKeyHandler( keyHandler );
> >>
> >>
> >> But your code in getCommonKeyHandler() looks strange.
> >>
> >> "Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
> >> news:dlssaq$ku5$1@news.eclipse.org...
> >> > Hello,
> >> >
> >> > I would like to know how can i enable users to use CTRL+Z combination
> > for
> >> > undo actions. I tried everything - but i cant get it to work
> >> > I am using RCP, and maybe this is the problem. I even transferred
Logic
> >> > example from plugin to a RCP application, from plugin CTRL+Z works,
but
> >> > from
> >> > RCP it doesnt. Maybe problem is in RCP?
> >> >
> >> > I have another RCP editor, and i dont know where in code i need to
> >> > "turn
> >> > on"
> >> > keyboard shortcut for undo. I have EditorActionBarContributor and
> >> >
> >> > protected void buildActions() {
> >> > addRetargetAction(new UndoRetargetAction());
> >> > }
> >> >
> >> > public void contributeToToolBar(IToolBarManager toolBarManager) {
> >> > toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
> >> > }
> >> >
> >> > public void contributeToMenu(IMenuManager manager) {
> >> > MenuManager editMenu = new MenuManager("&Edit",
> >> > IWorkbenchActionConstants.M_FILE);
> >> > manager.add(editMenu);
> >> > editMenu.add(getAction(ActionFactory.UNDO.getId()));
> >> > }
> >> >
> >> > protected void declareGlobalActionKeys() {
> >> > addGlobalActionKey(ActionFactory.UNDO.getId());
> >> > }
> >> > ...
> >> > in EditorPage:
> >> >
> >> > protected KeyHandler getCommonKeyHandler() {
> >> > if (sharedKeyHandler == null) {
> >> > sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
> >> > getMultipageBuildingEditor().getActionRegistry().getAction(
> >> > ActionFactory.UNDO.getId()));
> >> > }
> >> > return sharedKeyHandler;
> >> > }
> >> > ...
> >> > in MultiPageEditorPart
> >> >
> >> > protected void createActions(IEditorSite site) {
> >> > addStackAction(new UndoAction(this));
> >> >
> >> > ActionRegistry registry = getActionRegistry();
> >> > IActionBars bars = site.getActionBars();
> >> > String id = ActionFactory.UNDO.getId();
> >> > bars.setGlobalActionHandler(id, registry.getAction(id));
> >> >
> > getSite().getKeyBindingService().registerAction(registry.get Action(id));
> >> > ...
> >> >
> >> > But i cant do undo with CTRL+Z. Where is the proper place to do it?
> >> >
> >> > --
> >> > Pozdrav,
> >> > Radovan
> >> >
> >> >
> >>
> >>
> >
> >
>
>
Re: Keyboard shortcuts [message #203630 is a reply to message #203622] Wed, 23 November 2005 11:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: radicr.stop.spam.gmail.com

"Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
news:dm1hj5$ugs$1@news.eclipse.org...
> I forgot that i reduced code
> there are more lines in this method
>
> sharedKeyHandler = new KeyHandler();
> sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
> getMultipageBuildingEditor().getActionRegistry().getAction(
> ActionFactory.DELETE.getId()));
> ...
> and with this SWT.DEL - delete key from keyboard works, but CTRL+Z with
>
> sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
> getMultipageBuildingEditor().getActionRegistry().getAction(
> ActionFactory.UNDO.getId()));
>
> doesnt work.
>
> I have contributor in plugin.xml as well, but it still doesnt work.
> Thank you all for your help, but i am having a lot of problems with
eclipse.
> Main problem is that i didnt manage to get some extensive instructions
about
> this matter, so i am only guessing and trying to use magic in order for my
> keyboard actions work in gef.
>

In fact, what i want to say is that i dont know where in code i should put
proper lines that would enable my actions to work. Problem could be because
i am using MultiPageEditorActionBarContributor and i dont know where could i
do addRetargetAction(new UndoRetargetAction());
Maybe problem is in rcp, i have no idea.


> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> news:dlvvgg$qm$1@news.eclipse.org...
> > What I thought looked strange in getCommonKeyHandler() is
> >
> > if (sharedKeyHandler == null) {
> > sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0)
> >
> > i.e. you are putting something into the null sharedKeyHandler.
> >
> > Anyway, I don't need to add any keystrokes for the UndoAction because it
> is
> > a retarget action. My ActionBarContributor.buildActions() looks like
this:
> >
> > protected void buildActions() {
> > addRetargetAction( new UndoRetargetAction() );
> > ...
> > }
> >
> > and is specified as the contributorClass for my editor in plugin.xml.
> >
> >
> > "Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
> > news:dlulhe$u0k$1@news.eclipse.org...
> > > Thanks Felix,
> > >
> > > I use this
> > >
> > > private void createGraphicalViewer(Composite parent) {
> > > viewer = new ScrollingGraphicalViewer();
> > > viewer.createControl(parent);
> > > viewer.getControl().setBackground(parent.getBackground());
> > > viewer.setRootEditPart(new ScalableRootEditPart());
> > > viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)
> > > .setParent(getCommonKeyHandler()));
> > > ...
> > > }
> > >
> > > And this is why i use getCommonKeyHandler()
> > > I tried your code as well, but it doesnt work the same.
> > >
> > > "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> > > news:dlsub0$nt5$1@news.eclipse.org...
> > >> I just do the same thing as in GraphicalEditor.createActions() and
have
> > >> no
> > >> problems.
> > >> In configureGraphicalViewer() I also have this:
> > >> KeyHandler keyHandler = new GraphicalViewerKeyHandler( viewer );
> > >> viewer.setKeyHandler( keyHandler );
> > >>
> > >>
> > >> But your code in getCommonKeyHandler() looks strange.
> > >>
> > >> "Radovan Radic" <radicr.stop.spam@gmail.com> wrote in message
> > >> news:dlssaq$ku5$1@news.eclipse.org...
> > >> > Hello,
> > >> >
> > >> > I would like to know how can i enable users to use CTRL+Z
combination
> > > for
> > >> > undo actions. I tried everything - but i cant get it to work
> > >> > I am using RCP, and maybe this is the problem. I even transferred
> Logic
> > >> > example from plugin to a RCP application, from plugin CTRL+Z works,
> but
> > >> > from
> > >> > RCP it doesnt. Maybe problem is in RCP?
> > >> >
> > >> > I have another RCP editor, and i dont know where in code i need to
> > >> > "turn
> > >> > on"
> > >> > keyboard shortcut for undo. I have EditorActionBarContributor and
> > >> >
> > >> > protected void buildActions() {
> > >> > addRetargetAction(new UndoRetargetAction());
> > >> > }
> > >> >
> > >> > public void contributeToToolBar(IToolBarManager toolBarManager) {
> > >> > toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
> > >> > }
> > >> >
> > >> > public void contributeToMenu(IMenuManager manager) {
> > >> > MenuManager editMenu = new MenuManager("&Edit",
> > >> > IWorkbenchActionConstants.M_FILE);
> > >> > manager.add(editMenu);
> > >> > editMenu.add(getAction(ActionFactory.UNDO.getId()));
> > >> > }
> > >> >
> > >> > protected void declareGlobalActionKeys() {
> > >> > addGlobalActionKey(ActionFactory.UNDO.getId());
> > >> > }
> > >> > ...
> > >> > in EditorPage:
> > >> >
> > >> > protected KeyHandler getCommonKeyHandler() {
> > >> > if (sharedKeyHandler == null) {
> > >> > sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0),
> > >> > getMultipageBuildingEditor().getActionRegistry().getAction(
> > >> > ActionFactory.UNDO.getId()));
> > >> > }
> > >> > return sharedKeyHandler;
> > >> > }
> > >> > ...
> > >> > in MultiPageEditorPart
> > >> >
> > >> > protected void createActions(IEditorSite site) {
> > >> > addStackAction(new UndoAction(this));
> > >> >
> > >> > ActionRegistry registry = getActionRegistry();
> > >> > IActionBars bars = site.getActionBars();
> > >> > String id = ActionFactory.UNDO.getId();
> > >> > bars.setGlobalActionHandler(id, registry.getAction(id));
> > >> >
> > >
getSite().getKeyBindingService().registerAction(registry.get Action(id));
> > >> > ...
> > >> >
> > >> > But i cant do undo with CTRL+Z. Where is the proper place to do it?
> > >> >
> > >> > --
> > >> > Pozdrav,
> > >> > Radovan
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
> >
> >
>
>
Re: Keyboard shortcuts [message #204840 is a reply to message #203564] Thu, 08 December 2005 08:55 Go to previous message
Eclipse UserFriend
Originally posted by: stefan.helm1.lycos.de

Felix L J Mayer schrieb:
> What I thought looked strange in getCommonKeyHandler() is
>
> if (sharedKeyHandler == null) {
> sharedKeyHandler.put(KeyStroke.getPressed('Z', SWT.CTRL, 0)
>
> i.e. you are putting something into the null sharedKeyHandler.
>


Try this:

sharedKeyHandler.put(
KeyStroke.getPressed((char) ('z' - 'a' + 1), 'z', SWT.CTRL),
getActionRegistry().getAction(ActionFactory.UNDO.getId()));


This works for my GEF-Editor.




Stefan
Previous Topic:Is there an example of using a DirectEditPolicy with an AbstractTreeEditPart?
Next Topic:how to refresh editpart on editorpage
Goto Forum:
  


Current Time: Wed Apr 24 22:36:02 GMT 2024

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

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

Back to the top