Page 1 of 1

is the name of the selectedObject stored somewhere

Posted: Thu Apr 01, 2021 8:57 pm
by marksmithhfx
While in the IDE I would like to be able to edit the selectedObject (modify it's properties in script). Is there somewhere to find/retrieve the name of the selectedObject? (PS for those who read Andre's latest book; "Development Oriented Development", he references this function on Pg 24 but I can't figure out how he gets it to work). I've tried putting the name of the "selectedObject" into the msg box, or an answer dialog but I never get anything. However the msg box seems to get and display the name quite handily. Anyone know how it does that? (Hope I haven't asked too many questions!).

Thanks
Mark

Re: is the name of the selectedObject stored somewhere

Posted: Thu Apr 01, 2021 9:08 pm
by kdjanz
I don't have the book but you could try

Code: Select all

put the long name of the selectedobject
Kelly

Re: is the name of the selectedObject stored somewhere

Posted: Fri Apr 02, 2021 4:18 am
by andresdt
Hello, if what you are trying to do is a plugin. I advise you to read this post: https://livecode.com/how-to-create-plug ... e-8-0-ide/.
In it he explains how to subscribe to certain messages from the IDE. Among them to ideSelectedObjectChanged, within can call funcon the selectedobject or the selectedobjects. The last one will have a reference to a selected object on each line.

Re: is the name of the selectedObject stored somewhere

Posted: Fri Apr 02, 2021 4:26 am
by dunbarx
Hi.

Kelly nailed this with "the selectedObject". That is just what that function is designed for. In fact, it can return any number of selected objects.

Whatever the message box can do, a handler can do better. Are you sure that when your handler calls this function, that there is indeed an object selected? You will get empty if not. Otherwise it is very straightforward.

And the title of your post is interesting. But in the context of your question, nothing about a selected object is "stored" anywhere, simply by virtue of it being selected. But there is a property of an object that is selected, and is, not surprisingly, known as "the selected". This can be either true or false, depending on, well, I bet you already know. This is a basic underpinning of LiveCode. Properties reflect the current state of everything. They change, and are changed, by the user, the system, whatever. It is the setting and getting of properties that makes the world go round.

You have not asked nearly enough questions. Keep at it.

Craig

Re: is the name of the selectedObject stored somewhere

Posted: Fri Apr 02, 2021 7:29 am
by SparkOut
dunbarx wrote:
Fri Apr 02, 2021 4:26 am
Are you sure that when your handler calls this function, that there is indeed an object selected?
This.
If, for instance, you have created your own palette to choose properties to set, or a button to apply properties by running your handler, then you might find the selectedObject is no longer the object you originally selected.

Re: is the name of the selectedObject stored somewhere

Posted: Fri Apr 02, 2021 11:55 am
by marksmithhfx
SparkOut wrote:
Fri Apr 02, 2021 7:29 am
dunbarx wrote:
Fri Apr 02, 2021 4:26 am
Are you sure that when your handler calls this function, that there is indeed an object selected?
This.
If, for instance, you have created your own palette to choose properties to set, or a button to apply properties by running your handler, then you might find the selectedObject is no longer the object you originally selected.
Thanks everyone. You have given me lots to think about. If I get stuck again I'll post an example.

Cheers,
Mark

Re: is the name of the selectedObject stored somewhere

Posted: Fri Apr 02, 2021 1:11 pm
by andresdt
Hello marksmithhfx. Create a small sample extension using the LiveCode API. Which was introduced in version 8 and explained in the post I previously shared here.
If you are doing a plugin, which is what I understood. It is better to use this API.

It is a simple and improvable extension. What it does is display the properties of the selected object. As long as the object is not a widget: D.
Happy coding

Re: is the name of the selectedObject stored somewhere

Posted: Fri Apr 02, 2021 2:05 pm
by marksmithhfx
andresdt wrote:
Fri Apr 02, 2021 4:18 am
Hello, if what you are trying to do is a plugin. I advise you to read this post: https://livecode.com/how-to-create-plug ... e-8-0-ide/.
In it he explains how to subscribe to certain messages from the IDE. Among them to ideSelectedObjectChanged, within can call funcon the selectedobject or the selectedobjects. The last one will have a reference to a selected object on each line.
Hi Andre, I read the post with considerable interest, and I think you are correct, the mechanism is explained in/by the IDE API. Will give this a try (but I see you've posted a stack so I will be downloading that and giving it a try. Thanks a bunch)!!!

Mark

Re: is the name of the selectedObject stored somewhere

Posted: Tue Apr 06, 2021 3:34 pm
by marksmithhfx
andresdt wrote:
Fri Apr 02, 2021 1:11 pm
Hello marksmithhfx. Create a small sample extension using the LiveCode API. Which was introduced in version 8 and explained in the post I previously shared here.
If you are doing a pliugin, which is what I understood. It is better to use this API.

It is a simple and improvable extension. What it does is display the properties of the selected object. As long as the object is not a widget: D.
Happy coding
Hi Andre, I just tried unzipping this and apparently I am not equipped with an un-RAR application. Would you recommend one?

Thanks
Mark

Re: is the name of the selectedObject stored somewhere

Posted: Tue Apr 06, 2021 3:58 pm
by andresdt
marksmithhfx wrote:
Tue Apr 06, 2021 3:34 pm
andresdt wrote:
Fri Apr 02, 2021 1:11 pm
Hello marksmithhfx. Create a small sample extension using the LiveCode API. Which was introduced in version 8 and explained in the post I previously shared here.
If you are doing a pliugin, which is what I understood. It is better to use this API.

It is a simple and improvable extension. What it does is display the properties of the selected object. As long as the object is not a widget: D.
Happy coding
Hi Andre, I just tried unzipping this and apparently I am not equipped with an un-RAR application. Would you recommend one?

Thanks
Mark
Hello, I am on Win 10 and I use winRAR, here is the same example. Now in a ZIP

Re: is the name of the selectedObject stored somewhere

Posted: Tue Apr 06, 2021 4:32 pm
by marksmithhfx
andresdt wrote:
Tue Apr 06, 2021 3:58 pm
Hello, I am on Win 10 and I use winRAR, here is the same example. Now in a ZIP
Wonderful, thanks.

Re: is the name of the selectedObject stored somewhere

Posted: Tue Apr 06, 2021 8:31 pm
by kdjanz
marksmithhfx wrote:
Tue Apr 06, 2021 3:34 pm

Hi Andre, I just tried unzipping this and apparently I am not equipped with an un-RAR application. Would you recommend one?

Thanks
Mark
RAR Extractor Free is in the Mac App Store and worked for me.

Kelly

Re: is the name of the selectedObject stored somewhere

Posted: Sun Apr 18, 2021 10:54 pm
by marksmithhfx
kdjanz wrote:
Tue Apr 06, 2021 8:31 pm
RAR Extractor Free is in the Mac App Store and worked for me.

Kelly
Thanks!

Re: is the name of the selectedObject stored somewhere

Posted: Sat Dec 02, 2023 8:41 pm
by stam
andresdt wrote:
Fri Apr 02, 2021 1:11 pm
Hello marksmithhfx. Create a small sample extension using the LiveCode API. Which was introduced in version 8 and explained in the post I previously shared here.
If you are doing a plugin, which is what I understood. It is better to use this API.

It is a simple and improvable extension. What it does is display the properties of the selected object. As long as the object is not a widget: D.
Happy coding
Dear @andresdt, thank you for this code - it solved the issue I was just about to grapple with!
This forum is a goldmine ;)
But only thanks to the generosity of developers like yourself - thank you!

Stam