Key binding for Save and custom editors [message #464880] |
Fri, 16 March 2007 20:37 |
No real name Messages: 38 Registered: July 2009 |
Member |
|
|
I have an RCP application (using Eclipse 3.2.1) with a number of custom
editors (which I wrote). They all extend FormEditor or EditorPart.
I'm having problems associating the 'Save' key binding (Ctrl+S) to
tickle my editors' doSave() methods.....
I added a 'save' action to the menu bar in my ActionBarAdvisor class:
private IWorkbenchAction saveEditorAction;
protected void makeActions() {
saveEditorAction = ActionFactory.SAVE.create(window);
}
// note no 'file' menu....
protected void fillMenuBar(menuBar) {
MenuManager menu = new MenuManager ("MyApplication", "myApplication");
menu.add (saveEditorAction);
menuBar.add (menu);
}
When I start my application, the 'MyApplication' menu does, indeed, have
a 'Save' item in it and when I create an object and open one of my
editors and modify its contents, the 'Save' item is enabled and
selecting it causes my editors' 'doSave()' methods to be called (for my
various editors). Nice!
The 'Save' menu item also has a key binding for Ctrl+S on it. I didn't
do anything to enable this (e.g., no key binding in my plugin
descriptor). However, selecting Ctrl+S when I want to save the contents
of my editors does not cause the editor's doSave() method to be called.
I do have other key bindings for some other custom actions/commands that
work just dandy......
Here's the bit of debug output from my application. Enabling this
output was defined by PW (thanks, man)....:
KEYS >>> WorkbenchKeyboard.press(potentialKeyStrokes = [CTRL+S])
KEYS >>> WorkbenchKeyboard.executeCommand(commandId =
'org.eclipse.ui.file.save', parameters = {})
KEYS >>> not handled
hmmm. Not sure how to proceed.....
|
|
|
Re: Key binding for Save and custom editors [message #464915 is a reply to message #464880] |
Tue, 20 March 2007 14:30 |
No real name Messages: 38 Registered: July 2009 |
Member |
|
|
Figgered it out.... I neglected to call 'register (saveEditorAction)'
below after I added it to the menu. D'oh!
RacerNewbie wrote:
> I have an RCP application (using Eclipse 3.2.1) with a number of custom
> editors (which I wrote). They all extend FormEditor or EditorPart.
>
> I'm having problems associating the 'Save' key binding (Ctrl+S) to
> tickle my editors' doSave() methods.....
>
> I added a 'save' action to the menu bar in my ActionBarAdvisor class:
> private IWorkbenchAction saveEditorAction;
>
> protected void makeActions() {
> saveEditorAction = ActionFactory.SAVE.create(window);
> }
>
> // note no 'file' menu....
> protected void fillMenuBar(menuBar) {
> MenuManager menu = new MenuManager ("MyApplication", "myApplication");
> menu.add (saveEditorAction);
> menuBar.add (menu);
> }
>
> When I start my application, the 'MyApplication' menu does, indeed, have
> a 'Save' item in it and when I create an object and open one of my
> editors and modify its contents, the 'Save' item is enabled and
> selecting it causes my editors' 'doSave()' methods to be called (for my
> various editors). Nice!
>
> The 'Save' menu item also has a key binding for Ctrl+S on it. I didn't
> do anything to enable this (e.g., no key binding in my plugin
> descriptor). However, selecting Ctrl+S when I want to save the contents
> of my editors does not cause the editor's doSave() method to be called.
>
> I do have other key bindings for some other custom actions/commands that
> work just dandy......
>
> Here's the bit of debug output from my application. Enabling this
> output was defined by PW (thanks, man)....:
>
> KEYS >>> WorkbenchKeyboard.press(potentialKeyStrokes = [CTRL+S])
> KEYS >>> WorkbenchKeyboard.executeCommand(commandId =
> 'org.eclipse.ui.file.save', parameters = {})
> KEYS >>> not handled
>
> hmmm. Not sure how to proceed.....
|
|
|
Powered by
FUDForum. Page generated in 0.03701 seconds