I have a control array of PopupMenus and, unlike comboboxes and other controls, a contextual menu will never show up when defined in event handler ConstructContextualMenu (see test project in the feedback case above)
I tried to work around this by creating the contextmenu from the MouseDown event handler in a subclassed PopupMenu. I added the Menu Handlers directly to the subclassed control.
This seemed to work, until I noticed, that the MenuHandlers will always refer to properties of the first PopupMenu in the control array.
I have not figured out yet, how to identify and access the properties of the clicked control yet, but I’m still working on it …
Anyway, the not working ConstructContextualMenu handler is a bug. If you ran into this as well, please sign up to: http://feedback.xojo.com/case/33602
Are you perhaps running into <https://xojo.com/issue/30379> ? There is a different sequence of events in Win3 and Cocoa which confused me.
Nope. In the sample app, attached to the 33602 I have added nothing but the ConstructContextualMenu and ContextualMenuAction handlers. They do not fire.
No other conditions are set which might interfere. No MouseDown returning true or the like.
I’d expect it to work just like it works for a combobox, but it doesn’t.
For now I’m using this hackish workaround:
In MouseDown I save a reference to a global property of type myPopupMenu and then, in the MenuHandler of the subclassed PopupMenu, I use that global property to access the data (Like XojoScripts and more) of the clicked control.
This seems to work, so far … (but it is ugly and I would prefer to see a working ContextualMenu instead)
The OS X popup button (or popup menu as we call it) does not support contextual menus.
The underlying OS X control does not respond to contextual clicks.
[quote=89775:@Norman Palardy]The OS X popup button (or popup menu as we call it) does not support contextual menus.
The underlying OS X control does not respond to contextual clicks.[/quote]
AND WHY IS THIS NOT DOCUMENTED!?
I just have spent several useless hours on searching and trying and error…
Here, anyone who has the right to edit:
Because sometimes the docs are not quite complete/up to date/bug free
Or because the writer of that page didn’t know
Can’t you clone yourself ? No? Dammit…
[quote=89791:@Oliver Osswald]AND WHY IS THIS NOT DOCUMENTED!?
Now that I know about it, I’ve added a Note to the PopupMenu page.
You’re the first person to try this and we didn’t know about it until looking into your bug.
The Workaround is quite simple.
- Use Event MouseDown and IsContextualClick
See the Workaround-Example-Project in Feedback: <https://xojo.com/issue/33602>
Doing it in an own subclass might be the most convenient way.
Of course, Xojo could implement this workaround via Framework… but i don’t know if they like the idea of implementing a “non standard behavior”…