Contextual popupMenu

In a listbox I display a contextual popup menu which works fine.
Under a certain condition I do NOT want the popup menu to be displayed.
But if it has been displayed once, it always displays even it does not run through the base.append code, how can I avoid that ?

This is a known bug (Feedback # 31366).

Apparently it has been fixed and will not be present anymore in the next release:

[quote]Joe Ranieri on 23.07.2014 at 03:17
This case has been fixed and is waiting verification from our testing staff.[/quote]

Thanks,

[quote=118641:@Johann JFK]In a listbox I display a contextual popup menu which works fine.
Under a certain condition I do NOT want the popup menu to be displayed.
But if it has been displayed once, it always displays even it does not run through the base.append code, how can I avoid that ?[/quote]
Use my contextual menu class found on github https://github.com/CharlieXojo/classContextualMenu

[quote=118641:@Johann JFK]In a listbox I display a contextual popup menu which works fine.
Under a certain condition I do NOT want the popup menu to be displayed.
But if it has been displayed once, it always displays even it does not run through the base.append code, how can I avoid that ?[/quote]

Add this in ListBox.MouseDown. Nono is a global or window boolean property :

Function MouseDown(x As Integer, y As Integer) As Boolean if IsContextualClick = true and nono = true then return true end if End Function

When nono = true the ContextualMenu is suppressed.

I just found another way to handle this problem.
Instead of trying to hide the popup menu I append only 1 menu item with text explaining why …
that does the trick for me

thanks

The correct way would be, to show the regular popup menu and have all items disabled. On OS X this would be consistent with the Human Interface Guidelines.

Additionally, the ConstructContextualMenu event can be triggered for non-mouse clicks. Menus really should be built there and not in the MouseDown event by looking at IsContextualClick.

[quote=118723:@Michel Bujardet]Add this in ListBox.MouseDown. Nono is a global or window boolean property :

Function MouseDown(x As Integer, y As Integer) As Boolean if IsContextualClick = true and nono = true then return true end if End Function

When nono = true the ContextualMenu is suppressed.[/quote]

Hi Michel,

your code is nice to read, but = True is not needed:

Function MouseDown(x As Integer, y As Integer) As Boolean If IsContextualClick And nono Then Return True End If End Function

Yes, a bit less readable.

You add this to the top of the ConstructContextualMenu event.

#if TargetCocoa Static OldCMBase as MenuItem if OldCMBase<>nil then While OldCMBase.Count>0 OldCMBase.Remove(0) wend end if OldCMBase=Base #Endif

Jim, what does that actually do - in layman’s terms?
I have no idea what OldCMBase is?

Thanks.

[quote]Eli Ott"
The correct way would be, to show the regular popup menu and have all items disabled. On OS X this would be consistent with the Human Interface Guidelines.[/quote]

Eli - how and where should I disable the ContextualMenu Items?

Thanks.

[quote=118878:@Richard Summers]Eli - how and where should I disable the ContextualMenu Items?

Thanks.[/quote]
http://documentation.xojo.com/index.php/MenuItem.Enabled

While building the menu items and appending them to base, set the enabled property to False.

[quote=118876:@Richard Summers]Jim, what does that actually do - in layman’s terms?
I have no idea what OldCMBase is?

[/quote]

OldCMBase is just a place to hold a reference to the Base MenuItem from the last call to ConstructContexualMenu and allow you to clear it’s items.

As far as I can tell, the bug is in the way Xojo is storing/using the Base menuitem. If you populate the menu, it is stored for use in ContextualMenuAction. If you don’t populate it, it is discarded. The problem is that the internal menuitem is only cleared if the new Base is populated. Otherwise the old one hangs around and keeps popping up.

It’ll be nice to see this bug fixed.

[quote=118641:@Johann JFK]In a listbox I display a contextual popup menu which works fine.
Under a certain condition I do NOT want the popup menu to be displayed.
But if it has been displayed once, it always displays even it does not run through the base.append code, how can I avoid that ?[/quote]
I am trying to find out, how to use contextual popup menus in a listbox. But I can’t find the resources on how to do it. Any links or tips? Thanks.

Examples/Desktop/Controls/ListBox/ListBoxExample

Hey Axel, I am still using real studio. There is no such directory in my rs-app. Any other directions?

http://documentation.xojo.com/index.php/RectControl.ConstructContextualMenu

Thanks Michael. I might be a bit stupid, but I have no idea, how to pack this popup menu into a listbox cell.