PopupMenu ShowAt() problem

I am trying to use ShowAt to show a popup menu under the button that opens it. It works the first time but if I move the host and reopen the menu, the menu opens in the previous place, not under the button…on a different host it opens in another place…

Maybe the screen coordinates stuff does not work well and it wasn’t visible since Tracktion cannot be moved or minimized and always starts at top left of the screen (0, 0)?

Here is the code, the optionsButton is a child of the plugin editor

PopupMenu options;

options.addItem (1, “Play On Select”, true, playOnSelect );

int result = options.showAt( optionsButton->getScreenX(), optionsButton->getScreenY() + optionsButton->getHeight() );

no, there’s nothing wrong with the screen co-ords, and if you look at the normal show() method, you’ll see that it calls showAt() so there’s no problem there either.

It will try to move the menu to keep it on-screen, so maybe that’s affecting the position. Or maybe your button’s moved to a different place or invisible or been deleted?

The problem seems to be in getScreenX/Y methods. The compX_/compY_ are set only in my code init setBounds() and do not change later when the host plugin window (containing my plugin GUI) is moved on the screen.

I see this method componentMovedOrResized() in the VST wrapper but no one seems to call it…

I will use Show() for now, let me know if you find the problem


If there was anything wrong with getScreenX() then none of my code would work at all. Why don’t you step into the showAt() method and see what it does with the co-ords, it’s probably just moving the menu for some other reason.

I looked and stepped into the JUCE code, the problem is that getScreenX/Y return the same value for the button, even if I move the host window that contains my VST. I think the reason is that the component does not notice it was moved (along with its parent, the VST editor component). Look at my previous post, what componentMovedOrResized() supposed to do in the JUCE VST wrapper and who is suppsoed to call it?

In other words, the problem is not a bug in getScreenX/Y but probably a problem with the JUCE VST wrapper…

Ah - right, I see… sorry, I should have spotted that. Interesting problem, I’ll have to go and have a think about how to do a workaround.

thans, i have time, just moved to Show(), I think I also want to improve my code to show the menu when the mouse is clicked and not when released…just like it works in Tracktion!

BTW I added one line of code to JUCE so the treeview calls SelectedRowsChanged() when a node is selected and it works great…if you work on the treeview, please think if its efficient to know beforhand how many children a node have, maybe its good enough to know it has any and then do the +

My most needed JUCE fix is the scrollbars stepping over the list/tree…