The following article fixes “custom popup on macOS”, but I also encountered it on Windows with JUCE 6.1.6. Will there be any modifications to windows or other platforms?
checked DemoRunner, Windows/VS2017 build.
I’ve not had any issues with custom popup items on Windows. I am currently running JUCE 6.1.6 and the Custom items button in the DemoRunner works as expected. If you want to provide a simple code example example I can better understand what you’re trying to do.
I will explain it a little more carefully.
In my environment (though I don’t think there is a difference)
When I created an Item with PopupMenu :: addCustomItem (), that Item was no longer selected.
Instead, I created a simple Item with only a string without an image with PopupMenu :: addItem (), and now I can select it.
In the case of DemoRunner, if you click the colored part and PopupMenu does not close, there is a problem, and if PopupMenu closes, there is no problem.
In my code, the result was the same whether I checked with the return value of showAt () / show () with JUCE_MODAL_LOOPS_PERMITTED = 1 and received it with a lambda expression with JUCE_MODAL_LOOPS_PERMITTED = 0.
PopupMenu is generated in the mousedown method of other Component.
Again, it would be helpful if you could post of a code example of how you are using the PopupMenu component. This way I could understand why it is not working correctly for you.
Take a look at the documentation for
PopupMenu::addCustomItem(). There is a parameter called
triggerMenuItemAutomaticallyWhenClicked which when set to TRUE will close the popup menu after being clicked. Without looking at the JUCE demo for this, I assume that this parameter was set to false which prevents the popup menu from being closed when the colored part is clicked.
By design, a custom component in a PopupMenu will not be highlighted or selected like regular menu items. The solution to this which I have done in my project is to implement the behavior you want to see in your custom component by overriding class functions like Component::paint(), Component::mouseOver(), Component::mouseDown(), etc. For instance, if you want your custom component to be highlighted when the mouse is over it, then you can override Component::mouseOver(), Component::mouseExit(), and Component::paint() and set a variable to store when the mouse is over the component, then repaint the component according with the highlight color.
Hopefully this clears things up a bit for you!
@aguy-PG thank you, resoponse.
I’ve been using the first PopupMenu :: addCustomItem () for those who don’t use triggerMenuItemAutomaticallyWhenClicked since JUCE ver2 (to be exact, written by my project’s predecessor). There is one that uses, such as example / GUI / WidgetDemo.h: Line592.
This was the same behavior he had until JUCE2. * … JUCE6.1.4, but when I raised JUCE to 6.1.5, 6.1.6 he was no longer triggered by clicking the mouse.
If the specs changed in 6.1.5, I think the demo needs to be rewritten as well.
I see, this is a separate issue from my original post. I would suggest reaching out to the JUCE team directly to get them to take a look if this is the case. I think it may resolve your specific issue to use the second definition of PopupMenu::addCustomItem() because of this reason. It would not be a big change for you seeing as the second definition contains all the same parameters as the first, but includes the additional parameters that will resolve your issue.