Community
Participate
Working Groups
N20080217-0010 Add a shortcut to the open the context menu on the current selection. In Eclipse, some views have actions that are only available as context menu items on certain selections (e.g. Synchronize view's "Mark as Merged", or Package Explorer's "Assign Working Sets..."). These actions are currently very hard to use on the Mac without a mouse. The only way I found is to - enable MouseKeys, - move the cursor to a selected item, and then - press Ctrl+Numpad_5 Other platforms have a dedicated 'Menu' key on the keyboard and also open the menu on Shift+F10. Note that Mac OS X by default binds Shift+F10 to a slow version of Expose > Application Windows, so unless you can override this, we have to find another shortcut for the Mac. If you decide that SWT is not the right place to fill in this missing platform functionality, please move to Platform/UI to consider adding a command for opening the context menu (with a default key binding on the Mac).
CAR, is there a standard key that pops up a menu on the Mac? Scott, do you know of one?
No, there is no way to show a contextual menu from the keyboard. There is a Mac OS X bug tracking this, but it hasn't been touched in over 7 years. :-\
Wow! The Mac is so advanced in so many ways ... to be missing this? Ok, so the "right" platform behavior is not to have a key sequence for this and to make sure the voice over command to get it works. CAR, do you agree?
Assuming you already know what element has focus you could always fake a control-click event on the control.
How about this event? See CarbonEvents.h: /* * kEventClassWindow / kEventWindowContextualMenuSelect * * Summary: * A request to display a contextual menu. * * Discussion: * This event is generated by the standard window handler in * response to a contextual menu click in the content area of a * window. In response to such an event, the standard window handler * first checks if the click is on a control, and if so, calls * HandleControlContextualMenuClick. If the click was not on a * control, or if HandleControlContextualMenuClick returned that it * did not handle the click, then the standard window handler sends * kEventWindowContextualMenuSelect to allow the application to * provide its own customized contextual menu. The standard window * handler does not respond to this event itself. *
(In reply to comment #2) > No, there is no way to show a contextual menu from the keyboard. There is a > Mac OS X bug tracking this, but it hasn't been touched in over 7 years. :-\ So ... how about touching the bug now?-) I quickly googled for this before I opened this bug, and I found a number of forum posts from people looking for such a shortcut on the OS level.
Re comment 3, the VoiceOver key sequence is supposed to be: VO-Shift-M (In other words, Command-F5 to turn on VoiceOver, then Control-Option-Shift-M to get a context menu). Unfortunately, this doesn't work in Eclipse, on either Tiger or Leopard. (It does work in Finder and Safari). So our accessibility implementation is missing something... I believe that if I add the "AxShowMenu" action to a control when a pop-up menu is added, i.e. in setMenu(Menu), then VoiceOver (or any other assistive tool) will be able to pop up the context menu when the user types VO-Shift-M. I'll let you know. Re comment 6, that'd be great! Scott, you could win the award for "oldest bug fixed" if you tackled this one. ;) Is there anything in the radar to give a hint as to why the bug was never fixed? Re comment 4 and 5, thanks - looks promising. I'll try faking the event after I try fixing the VO-Shift-M not working problem. (That may seem to be the wrong order to fix the problems in, but I am looking at VO problems at the moment... Besides, maybe that will give you time to fix the 7 year old bug before I have to fake the event <grin>).
If you put in code to test when to fake the event, you may as well just open the menu in that place rather than faking the event, right?
The AXShowMenu stuff is about 80% working - still needs some cleanup, and some thinking about which x, y to use to pop up the menu <g> before I release it. Re comment 8 - good point :) I had to write a little "showMenu(x, y)" helper method for the AXShowMenu stuff anyhow, so now I only need to look for... what? Shift+F10? Or I guess we could copy VoiceOver and use Control-Option-Shift-M ? Steve? Scott?
The VoiceOver shortcut Control-Option-Shift-M also does not work on Cocoa.
For what it's worth, I found this (marginally useful) information on Wikipedia: "A keyboard alternative for Mac OS is to enable Mouse keys in Universal Access. Then, depending on whether a laptop or compact or extended keyboard type is used, the shortcut is Function+Ctrl+5 or Ctrl+5 (numeric keypad) or Function+Ctrl+i (laptop)." I wasn't able to try this on a laptop, and it didn't work with a compact keyboard (no numpad) that I tried, but it did work with an extended keyboard (with numpad). The down side is that you have to turn on mousekeys, which renders your numpad useless for typing numbers. Also, there are many VoiceOver commands that use the numpad, so I doubt VoiceOver users want MouseKeys on. Also, it seemed to make my mouse behave strangely (popping up menus everywhere I clicked) until I typed ESC.
Yes, MouseKeys is not great, see comment 0. This shortcut should work on the current selection and not at the location of the mouse. I recently filed bug 357532 for Platform UI support for this, but I haven't verified the final implementation yet. Replacing that implementation with a native SWT version would still be nice.
Re comment 12: Rats - I thought it was working on the focused item, but I didn't notice that I just happened to have the mouse in the right place when I tried it. Duh. OK, so the following keyboard insanity does work, for what it's worth. However it is "suboptimal" (and that's an understatement). - Beforehand, go to System Preferences, Universal Access, Mouse, and check the box for "Press the Option key 5 times to turn MouseKeys on or off". 1) move focus, using the keyboard, to the item you want a context menu for. 2) turn on VoiceOver (command+F5) Notice that the VO cursor (black box) is on drawn around your focus item. 3) secret ingredient: "move mouse to VO cursor" is control+option+command+F5 4) now turn on MouseKeys (option 5 times) 5) control+numpad 5 to bring up the context menu (same as control+mouse click) 6) use the menu 7) at some point you will want to turn off MouseKeys (option 5 times) 8) if you are not a VoiceOver user, turn off VoiceOver (command+F5) Looking at bug 357532: can the context menu shortcut (ctrl+shift+F10) be reassigned by the user? This might end up being desirable, because some folks might prefer something else. For example, some Mac apps have chosen ctrl+space for context menu (yes, I know we use that for autocomplete), and others have chosen shift+F10 (to be the same as Windows and Linux). Sure wish Mac had assigned a system shortcut for it... apparently their philosophy is that all commands should be accessible by other menus or shortcuts. Oh well.
Created attachment 207605 [details] old patch Since I mentioned in comment 9 that I had something mostly working (almost 4 years ago - yikes), I thought it might be helpful if I searched for that patch on my old Mac hard disk and saved it in this bug report so that it isn't lost. Unfortunately, it was for carbon, however the cocoa code should be similar.
Fixed in 3.8 and 4.2: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=40e15e68f5fa0b6fe1e8ba9d3ffd820b3dca362f Note that the context menu pops up at the mouse coordinates, instead of over the focused item. However, the user is still able to arrow through the items, and VoiceOver speaks them. The strange location of the context menu when it is activated from the keyboard is a very old bug that I do not have time to fix at the moment: https://bugs.eclipse.org/bugs/show_bug.cgi?id=110005
FYI, the fix I just committed makes Control-Option-Shift-M work under VoiceOver. Bug 357532 covers providing a key binding for use without VoiceOver.
Backported to Eclipse 3.7.2. http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=R3_7_maintenance&id=4fb5659e7162f883cc65fef16a35153b2ff9c7b9
Thanks so much for adding this feature, I've really missed it on Mac.
(In reply to comment #18) Thanks for the confirmation. I'm just curious: Do you really use the VoiceOver shortcut Control+Option+Shift+M, or do you use Shift+F10 from bug 357532?
Ah sorry, I'm actually using SHIFT+F10.