get selected GUI Object

Falk Grieffenhagen's icon

Hi List,

maybe this one sounds silly but somehow its not...at least not for me...

If I have some UI objects I can select only one of them this gets highlighted for example the live.gain~ gets the filled triangle and the frame..

my question: can I easily(!) get the information which one is selected? the object could have a scripting name, which could get exposed in some way once selected.

If I have 2 live.gain~ objects and click on them I see it working (the patcher knows which one is selected) but I´d like to use this information for opening an detail editor or similar stuff

its like the radio group object: only one option can be selected everything else gets deselected.

Sure I can patch this with ubuttons und numbers first reset all to 0 (unselected) and after set the last clicked one to 1, this I would call not "easily". I feel there might be some feature that is more elegant, something like a "getselectedobjectname" message to the thispatcher object, which currently doesn't exist.

thanks Falk

Roman Thilenius's icon

just to summarize, you want to create something which works like the object inspector does?

Falk Grieffenhagen's icon

Hi Roman,

well yes which has that approach of selecting and do focussed editing like the inspector.

thanks Falk

TFL's icon

I'm not aware of a way to know which object is in focus sadly.

But there is a workaround based on scripting names and [hover] allowing to know when an object is being clicked. It won't work if the object gets focused by using the select message.

Here's an example allowing to show and edit the bgcolor of clicked object (and also know when no object is selected)

Max Patch
Copy patch and select New From Clipboard in Max.

EDIT: added filtering, and removed unbinding when clicking outside of the selected object, allowing for easier bgcolor change.

Falk Grieffenhagen's icon

Hey TFL,

wow yes! with this I can work fine for what I want Its the kind of approach I thought it might be existing....and voilà!

thanks again for your help

falk

Roman Thilenius's icon

oh great, yes, a combination of hover&mousestate do all of it already, at least as long as we are on the same patcher level.

TFL's icon

Yes, I did something similar with bpatcher compatibility and it implied a [hover] in each bpatcher to get objects varname at this levels, adding an identifier for this specific bpatcher, and handling everything else from the main patch.