is the name of the selectedObject stored somewhere

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 672
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

is the name of the selectedObject stored somewhere

Post by marksmithhfx » Thu Apr 01, 2021 8:57 pm

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
macOS 10.15.7, Xcode 11.5, LC 9.6.1, iOS 13.6.1
Targets: Mac, iOS

kdjanz
Posts: 279
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: is the name of the selectedObject stored somewhere

Post by kdjanz » Thu Apr 01, 2021 9:08 pm

I don't have the book but you could try

Code: Select all

put the long name of the selectedobject
Kelly

andresdt
Posts: 48
Joined: Fri Aug 16, 2019 7:51 pm

Re: is the name of the selectedObject stored somewhere

Post by andresdt » 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.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7572
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: is the name of the selectedObject stored somewhere

Post by dunbarx » Fri Apr 02, 2021 4:26 am

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

SparkOut
Posts: 2455
Joined: Sun Sep 23, 2007 4:58 pm

Re: is the name of the selectedObject stored somewhere

Post by SparkOut » 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.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 672
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: is the name of the selectedObject stored somewhere

Post by marksmithhfx » Fri Apr 02, 2021 11:55 am

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
macOS 10.15.7, Xcode 11.5, LC 9.6.1, iOS 13.6.1
Targets: Mac, iOS

andresdt
Posts: 48
Joined: Fri Aug 16, 2019 7:51 pm

Re: is the name of the selectedObject stored somewhere

Post by andresdt » 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
Attachments
Plugin Template.rar
(1.52 KiB) Downloaded 28 times
Image

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 672
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: is the name of the selectedObject stored somewhere

Post by marksmithhfx » Fri Apr 02, 2021 2:05 pm

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
macOS 10.15.7, Xcode 11.5, LC 9.6.1, iOS 13.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 672
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: is the name of the selectedObject stored somewhere

Post by marksmithhfx » 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
macOS 10.15.7, Xcode 11.5, LC 9.6.1, iOS 13.6.1
Targets: Mac, iOS

andresdt
Posts: 48
Joined: Fri Aug 16, 2019 7:51 pm

Re: is the name of the selectedObject stored somewhere

Post by andresdt » Tue Apr 06, 2021 3:58 pm

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
Attachments
Plugin Template.zip
(1.54 KiB) Downloaded 13 times
Image

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 672
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: is the name of the selectedObject stored somewhere

Post by marksmithhfx » Tue Apr 06, 2021 4:32 pm

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.
macOS 10.15.7, Xcode 11.5, LC 9.6.1, iOS 13.6.1
Targets: Mac, iOS

kdjanz
Posts: 279
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: is the name of the selectedObject stored somewhere

Post by kdjanz » Tue Apr 06, 2021 8:31 pm

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”