Action accelerator [message #277615] |
Tue, 14 December 2004 09:27  |
Eclipse User |
|
|
|
Originally posted by: james.willans.xactium.com
I am defining a set of actions which I need to provide a keyboard
accelerators to. I've read the documentation which talks about how
Commands are the preferred way of doing this. However in my case they are
inappropriate since they must be defined in the plugin manifest whereas my
actions are calculated dynamically once the plugin is already running in
the RCP app. Therefore I would like to use the old method of setting
IAction.setAccelerator(SWT.CTRL | 'S') for example. Although this
displays the accelerator key next to the action label (CTRL + S) the
accelerator has no effect. What am I doing wrong and how do I get this
working?
Thanks.
James
|
|
|
|
|
|
Re: Action accelerator [message #277675 is a reply to message #277663] |
Wed, 15 December 2004 04:28   |
Eclipse User |
|
|
|
Originally posted by: james.willans.xactium.com
Wei,
Thanks for your response. I'm not sure this is the problem since I have
tried accelerators that do not have any equivalent bindings in the
workspace (e.g. ALT + 'B'). Any further suggestions?
Also, does anyone know if it is possible to uninstall those actions that I
don't require such as Save (or prevent their installation in the first
place), these have no meaning in my RCP application? Which plugin
installs these?
James
wei zhang wrote:
> in AbstractTextEditor, CTRL + S has been used to save action, so you
> cannot use this accelerator to your action.
> if you wanner used your action to instead of save action, you can use this
> code
> -------------------------------------------
> boolean isEnable = ......;
> IActionBars actionBars =
>
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor().getEditorSite().getActionBars();
> Object o = actionBars.getGlobalActionHandler(ActionFactory.COPY.getId() );
> if (o instanceof MyCopyAction) {
> ((MyCopyAction) o).setEnabled(isEnable);
> } else {
> Action copyAction = new MyCopyAction();
> copyAction.setEnabled(isEnable);
> actionBars.setGlobalActionHandler(ActionFactory.COPY.getId() ,
> copyAction);
> }
> actionBars.updateActionBars();
> -------------------------------------------
> or in your editor, override createActions() method, and bind your action
> on ITextEditorActionConstants.COPY key.
> you can see AbstractTextEditor.createActions()method for more info.
> hope useful.................
> James Willans wrote:
>> Anyone?
>> James Willans wrote:
>>> A little more detail. I am adding these actions to an implementation of
>>> AbstractTextEditor and I am calling
>>> AbstractTextEditor.setAction(id,action). Looking at this method, it
>>> should add the actions to the editors key binding service.
>>> Any ideas?
>>> James
>>> James Willans wrote:
>>>> I am defining a set of actions which I need to provide a keyboard
>>>> accelerators to. I've read the documentation which talks about how
>>>> Commands are the preferred way of doing this. However in my case they
are
>>>> inappropriate since they must be defined in the plugin manifest whereas
my
>>>> actions are calculated dynamically once the plugin is already running in
>>>> the RCP app. Therefore I would like to use the old method of setting
>>>> IAction.setAccelerator(SWT.CTRL | 'S') for example. Although this
>>>> displays the accelerator key next to the action label (CTRL + S) the
>>>> accelerator has no effect. What am I doing wrong and how do I get this
>>>> working?
>>>> Thanks.
>>>> James
|
|
|
|
Re: Action accelerator [message #277791 is a reply to message #277686] |
Fri, 17 December 2004 04:16  |
Eclipse User |
|
|
|
Originally posted by: james.willans.xactium.com
Bug: 81494
James Willans wrote:
> I've spent two days trying to solve this problem to no avail. I see from
> the help system documentation that there is "no public API for declaring
> commands, categories [and] key bindings". Can this really be the case?
> Is it really safe to assume that all applications know prior to runtime
> the precise actions/commands that they wish to offer? I know that it
> isn't in my case and that such an assumption is causing all kinds of
> problems. Could someone with knowledge of the key binding architecture
> comment on this please?
> James
> James Willans wrote:
>> A little more detail. I am adding these actions to an implementation of
>> AbstractTextEditor and I am calling
>> AbstractTextEditor.setAction(id,action). Looking at this method, it
>> should add the actions to the editors key binding service.
>> Any ideas?
>> James
>> James Willans wrote:
>>> I am defining a set of actions which I need to provide a keyboard
>>> accelerators to. I've read the documentation which talks about how
>>> Commands are the preferred way of doing this. However in my case they are
>>> inappropriate since they must be defined in the plugin manifest whereas my
>>> actions are calculated dynamically once the plugin is already running in
>>> the RCP app. Therefore I would like to use the old method of setting
>>> IAction.setAccelerator(SWT.CTRL | 'S') for example. Although this
>>> displays the accelerator key next to the action label (CTRL + S) the
>>> accelerator has no effect. What am I doing wrong and how do I get this
>>> working?
>>> Thanks.
>>> James
|
|
|
Powered by
FUDForum. Page generated in 0.03939 seconds