Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Keybinding does not work in MessageDialog
Keybinding does not work in MessageDialog [message #290940] Mon, 05 September 2005 09:00
Eclipse UserFriend
Originally posted by: jsetya.yahoo.com

Hi all,

I need to bring up the following thread again since they don't work for me
:

http://dev.eclipse.org/newslists/news.eclipse.platform/msg43 081.html

and

http://dev.eclipse.org/newslists/news.eclipse.platform/msg42 087.html

I've just migrate from 3.1M5 to 3.2M1 in order to be able to use
IHandlerService mechanism to register keybinding in MessageDialog, but so
far with no luck.

1. The links above suggest that I use
IWorkbench.getAdapter(IHandlerService.class) to obtain instance of
IHandlerService, but how can I get reference to IWorkbench from within the
MessageDialog subclass ?

2. I try to pass IWorkbenchPart to the dialog so I can get the
IHandlerService reference by the following code (Is this the correct way
to get IWorkbench ?) :

IHandlerService service =
(IHandlerService)part.getSite().getWorkbenchWindow().
getWorkbench().getAdapter(IHandlerService.class)

Then register the ActionHandler with Ctrl+N accelerator :

service.activateHandler("org.eclipse.ui.newWizard",new ActionHandler(
getNewRecordAction()));

private IAction getNewRecordAction()
{
IAction action = new Action()
{
public void run()
{
System.out.println("New Record");
}
};

action.setActionDefinitionId("org.eclipse.ui.newWizard");
action.setText("New");

return action;
}

The menu item and the accelerator actually shows up in the menu but when I
press Ctrl+N, nothing happens.

I also try to turn on the debug options with the following results :

KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x0, keyCode =
0x40000, time = 22787847, character = 0x0)
KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x40000, keyCode
= 0x6e, time = 22788017, character = 0xe)
KEYS >>> WorkbenchKeyboard.press(potentialKeyStrokes = [CTRL+N])
KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x0, keyCode =
0x10000, time = 22789119, character = 0x0)


Am I missing something ?

Thanks in advanced.


Setya
Previous Topic:Refreshing Syntax Colouring
Next Topic:UI changes on plugin load
Goto Forum:
  


Current Time: Fri Apr 26 12:40:55 GMT 2024

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

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

Back to the top