getPopupMenuTarget
-
I can't find any information about this, what is the function and how to use it?

-
@ulrik I asked Claude/Cursor and it said it's an internal C++ function that doesn't have much use in HISE script.

What it does behind the scenes:
When you set up a popup menu on a component (using popupMenuItems and allowCallbacks = "Popup Menu Only"), the engine shows a popup menu on click and then fires your callback with two arguments:
- argument[0] — the component (this is the return value of getPopupMenuTarget)
- argument[1] — the selected menu index
So the engine already calls getPopupMenuTarget for you internally and passes the result as the first argument to your callback. You never need to call it yourself.
The practical scenario it supports:
The main reason it exists is for ScriptDynamicContainer (the ScriptContainerComponent). In a dynamic container with child elements, if each child has a popup menu, you need to know which child was right-clicked. The override ensures your callback receives a reference to the specific child rather than the parent container. But again, this happens automatically — you just receive the correct reference in your callback.
Why it's in the docs:
It appears in the public API docs because HISE auto-generates documentation for all methods on script component classes, including internal/virtual ones. The description "Override this if you want to change the component parameter" is C++ language leaking through — you can't override virtual methods from HISEScript.
TL;DR: You wouldn't call it in HISE script. It's an internal plumbing method. What you would use is the popup menu system itself — setting popupMenuItems, popupOnRightClick, and allowCallbacks on a Panel or Image, then handling the result in your mouse callback where the target component is already provided as the first argument.
-
@dannytaurus said in getPopupMenuTarget:
Thank you!