TMenuItem.OnClick doesn't work for submenu items
Original Reporter info from Mantis: zpeterson @boramis
-
Reporter name: Zoë Peterson
Original Reporter info from Mantis: zpeterson @boramis
- Reporter name: Zoë Peterson
Description:
When mousing over a menu item that shows a submenu its OnClick handler should be called. Sample project and patch included in zip
Steps to reproduce:
Expand the attached zip and compile it with Cocoa and Carbon and compare the difference in behavior when mousing over the top-level menus to show their submenus. When mousing over the "Change" one the form background should change color.
Under Windows and Carbon, the background changes every time the mouse goes over the item to show the menu. Qt does too, but only if it's on a dropdown rather than a top-level menu item. The Gtk widgetset doesn't seem to support it at all, at least on Ubuntu with the detached menus.
Additional information:
The attached patch wires the OnClick handler up to [NSMenuDelegate menuNeedsUpdate:] callback. That causes OnClick to be called, with two differences from the other widget sets:
-
OnClick is only called once per tracking session. That is, if you click into the menu and force it to drop down it will call it once, but then it won't call it again until you click away from the menu.
-
OnClick is called during keyboard hotkey handling.
NSMenuDelegate also has a menuWillOpen: callback that would work, and matches the existing widget sets better (OnClick is called on every mouse over, and isn't called for hotkey handling). Unfortunately, the documentation specifically says that you can not modify the menu in menuWillOpen, so it isn't useful for actually customizing it on demand. That's what we're using it for, so menuNeedsUpdate: is preferable, even with the caveats.
Mantis conversion info:
- Mantis ID: 30808
- Version: 1.7 (SVN)
- Fixed in revision: 61261 (#473ea12b)