(Oh god, how I hate this forum software! Just lost all my text again because it tries to be so “smart”. And then, as another bug, it would not accept my posting after I waited too long before submitting it.)
When I use MenuItem.Popup, the menu opens by default with the top row under the mouse.
However, I need it to open so that another row is under the cursor, like here:
(The menu opened where the blue selection is show)
The old Carbon menu function PopUpMenuSelect allowed me to do this (selectedRow parameter):
declare function PopUpMenuSelect lib "Carbon" (handle as Integer, top as Integer, left as Integer, selectedRow as Integer) as Integer
I cannot use that function in Cocoa builds, though, since I only get the NSMenu… handle, not the Carbon handle.
I realize that I can shift the menu up/down by giving a different Y coordinate to the Popup(x,y) call, but that requires that I know the exact dimensions of the menu, including the height of individual rows, which I don’t (especially since I alter its font size dynamically).
I dont see a method on NSMenu to programmatically hilight a row. You can get the currently hilighted row with the - (NSMenuItem *)highlightedItem method but not set it.
Btw, I see the standard behavior on Mac is to open the menu without hilighting a row. This is on Finder and every other application I checked. Do you really need this?
The hightlight comes from the fac that the item is under the mouse. That’s normal and not part of my question. What I want to know is how to make sure that a specific row does appear under the mouse.
[quote=60159:@Thomas Tempelmann](Oh god, how I hate this forum software! Just lost all my text again because it tries to be so “smart”. And then, as another bug, it would not accept my posting after I waited too long before submitting it.)
When I use MenuItem.Popup, the menu opens by default with the top row under the mouse.
However, I need it to open so that another row is under the cursor, like here:
(The menu opened where the blue selection is show)
The old Carbon menu function PopUpMenuSelect allowed me to do this (selectedRow parameter):
declare function PopUpMenuSelect lib "Carbon" (handle as Integer, top as Integer, left as Integer, selectedRow as Integer) as Integer
I cannot use that function in Cocoa builds, though, since I only get the NSMenu… handle, not the Carbon handle.
I realize that I can shift the menu up/down by giving a different Y coordinate to the Popup(x,y) call, but that requires that I know the exact dimensions of the menu, including the height of individual rows, which I don’t (especially since I alter its font size dynamically).