Community
Participate
Working Groups
In the wonderful key binding and command framework... it seems menus aren't loved. It would be nice to have a contextId that can be registered against menus so you can have your key binding fire when a menu is displayed, for example, File->Import I believe the Help component currently gets at having its bindings fired due to the old JFace Actions. I think there was something there that checked for F1 or whatever Help had registered. Other people want to have their commands invoked also :) Another idea would be to have a contextId of org.eclipse.ui.contexts.all or everywhere... something to say that your keybinding will be hit anywhere in the workbench. What are your thoughts Paul? How hard do you think this is to implement, I can spare some cycles as if this is working, this would make my Plug-in Spy work so much easier.
Hmmm, where to start ... :-) Yeah, when a menu is up we no longer receive key binding events. They're just ... gone. Help is a special case. SWT fires a HelpEvent when a menu item has a help listener and the user hits SHIFT+F12 Is this because you need to execute your command when the user has selected a menu item (to provide information about it)? PW
Correct paul, I would like to receive information about the menu based on the execution of my key binding. Why should there be special cases, why can't everyone participate in the love :)?
and this should be in Platform UI's bucket, I must've been sleepy last night.
Paul, any sneaky way to do this via reflection possibly as a temporary workaround?
(In reply to comment #4) > Paul, any sneaky way to do this via reflection possibly as a temporary > workaround? > I talked to Steve and he said that as long as the menu is up, the OS will eat the key events. Another option is to set up a command that will display info about the *next* event. When the attached code is run, it adds a global filter. If you then select a menu item, it will eat the selection event and you have the widget. For commands and actions, getData() should have some form of ContributionItem. PW public class FindThatItemHandler extends AbstractHandler { private Listener listener = new Listener() { public void handleEvent(Event event) { event.display.removeFilter(SWT.Selection, this); System.out.println("Disarmed"); if (event.widget instanceof MenuItem) { MenuItem item = (MenuItem) event.widget; System.out.println(item.getText()); System.out.println(item.getData().getClass().getName()); event.doit = false; event.type = SWT.None; } } }; public Object execute(ExecutionEvent event) throws ExecutionException { Display display = HandlerUtil.getActiveWorkbenchWindowChecked(event) .getShell().getDisplay(); display.addFilter(SWT.Selection, listener); System.out.println("Armed"); return null; } }
Paul, you're officially a genius. My next question would be, is this type of thing possible for items on the toolbar?
n/m Paul, you're a genius.
Does this need more love? PW
Updated as per http://wiki.eclipse.org/Platform_UI/Bug_Triage PW
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.