createPopupMenu not working with Ubuntu (Xorg)

Using system.gui.createPopupMenu to instantiate simple quick-menus on templates.

Works as expected on every Windows install I’ve tried. Recently was ‘gifted’ a Xubuntu development environment by the almighty cloud. Even the most basic case found in the user manual fails to popup.
Confirmed the issue with another vanilla Ubuntu VM.

Any tips or workarounds to ensure this plays well on all platforms?

After pausing for a moment to actually reflect on the linked docs, this passage stood out:

Then, call the show(event) function on both the mousePressed and mouseReleasedevents on your component. The reason for this is that different operating systems (Windows, Linux, MacOS) differ in when they like to show the popup menu. The show(event) function detects when the right time is to show itself, either on mouse press or release. See the examples for more.

Indeed including the same code in BOTH mousePressed and mouseReleased seems to work as intended.

1 Like

Still wondering about this bit though:

It is best to have the menu object created only once via an application specific library function.

Does that imply instantiate from a shared script? Or call createPopup once during startup and store the reference in a global somehow?

There are a variety of options. I would tend to keep the scope as local as possible - add a custom method to the component which will construct the popup menu, then cache the constructed menu locally (using self.putClientProperty. Structure the function so that it first looks for a cached instance, and then if one is not found, builds it (and puts it in the cache!) then returns it. Then just call your custom method from each mouse event handler.

1 Like