Referencing objects when editing a group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
stan
Posts: 10
Joined: Thu Jul 17, 2008 10:28 am

Referencing objects when editing a group

Post by stan » Sat Nov 30, 2024 3:51 pm

I know this has been discussed before but I haven't been able to find an answer!!

The problem:

I have an app designed in a fairly traditional way - main stack simply appears as a splash screen but holds most of the functions & commands for the app as well as the app's menu bar. Users then work on stack files as files they can create/save etc.

Each stack file can have numerous cards and each card has a group called "dropper" that handles the drag drop event and allows the user to drag a variety of things onto the page - e.g. links to files, text snippets, images. On dropping an item, the code creates a new object within Group "dropper". This might be an image, a field or another group.

selectgroupedcontrols is true for group "dropper" to allow the user to manipulate objects they have dragged onto the page but is false for any group created WITHIN group "dropper" as these need to behave as single entities.

I want to allow the user to change the layer of the objects within group "dropper".

There appear to be two approaches to this:

1) set the relayerGroupedControls to true - which works fine until you have groups within the group you're editing. I find changing the layer of an object regularly results in it being merged into one of the groups within group "dropper" rather than being repositioned with respect to its layer IN group "dropper"

2) start editing group "dropper" - this seems the safest approach as it only "sees" the objects in the group and their respective layers. Indeed, if I execute my "Move forwards" script from a button on the card currently being worked on, the code works fine. However, when the same code is executed from the app's menubar it constantly throws an error about the object/background not being found. So my question is "How do you reference an object when editing its owner group".

The code goes like this:

start editing group "dropper" of card ID cID of stack tTop

set the layer of control ID tselobjID to currentvalue+1

(where tselobjID is the ID of the object selected and currentvalue is the current layer value for the object)

As I've said, this code works when executed from the card containing group "dropper" but NOT when executed from the app's menubar. I've tried all sorts of ways of referencing the object - including being specific about the card ID and the stack name - all of which work fine until you "Start editing group "dropper"" - at which point the point of reference for LiveCode I guess changes to just be the contents of the group but I can't find anyway of then referencing the object!!!!

Any advice gratefully received!

Stan

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Referencing objects when editing a group

Post by jacque » Sun Dec 01, 2024 7:29 pm

When setting the layer, use the long ID. Right now I think it's looking for the control in the splash stack. Or specify the stack in the command:

Code: Select all

set the layer of control ID tselobjID of stack tTop to currentvalue+1
Edit: Oh wait, you said you tried that...

What's the long ID if you manually go into edit mode?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stan
Posts: 10
Joined: Thu Jul 17, 2008 10:28 am

Re: Referencing objects when editing a group

Post by stan » Mon Dec 02, 2024 1:25 pm

Good idea!!!! - the long ID is the same in group edit mode APART from the fact that the reference to the parent group is dropped.

Just tried using the form "control ID of card ID of stack ID" when in group edit mode and that works.

Many thanks

Stan

Post Reply