Page 1 of 1
Can LC set an objet to the top laye of a group with script? - Solved
Posted: Mon May 25, 2020 11:21 am
by DR White
Can LC set an objet to the top laye of a group with script?
Thanks,
David
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 12:44 pm
by jmburnod
Hi David
Yes LC can
Something like that:
Code: Select all
on setLayerControl pControl,pGroup
put getMaxLayerInGrp(pGroup) into tTopLayerOfGrp
set the relayerGroupedControls to true
relayer control pControl after control tTopLayerOfGrp
set the relayerGroupedControls to false
end setLayerControl
function getMaxLayerInGrp pGroup
put the num of controls of group pGroup into tNbControls
put the short name of control tNbControls of group pGroup into rMaxLayerInGrp
return rMaxLayerInGrp
end getMaxLayerInGrp
Best regards
Jean-Marc
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 12:45 pm
by richmond62
-
So . . . I would be inclined to ungroup the group, reorder the objects and then regroup them again.
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 1:03 pm
by richmond62
-
2 lines of code!
Code: Select all
on mouseUp
ungroup group "bunch"
group img "three" and img "two" and img "one"
end mouseUp
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 1:53 pm
by DR White
Thanks for the suggestions.
The group I am working with is in a mobile scroller with more than 40 items in the group,
witch are being inserted by the user. I need to keep my pointer on top of the newly inserted
objects. As a work around, i am currently deleting and copying the pointer after each new object is
inserted to keep the pointer on top. It works OK, but I thought the might be a better way.
Thanks both of you for your help,
David
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 3:08 pm
by jmburnod
Hi David,
Did you try to adapt scripts i posted to your context ?
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 3:29 pm
by dunbarx
Richmond.
That was adorable.
David.
But is it necessary to do anything more than:
Code: Select all
set the screenMouseLoc to the loc of last control
(You have to do the usual calcs to adjust loc of the card window to screen "0,0".)
This begs whatever method you use adding the newly created control to the group. The only reason I am posting is because the original question was how to "locate" the newly added control, not how to add the control to the group. For example, you could copy the new control to the group, and then delete the original.
Fun stuff...
Craig
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 8:51 pm
by DR White
Craig,
I don't see how "set the screenMouseLoc to the loc of last control" is going to change a layer property.
Jean-Marc,
I don't understand what "getMaxLayerInGrp(pGroup)" is.
Thanks,
David
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 9:48 pm
by dunbarx
David.
I don't see how "set the screenMouseLoc to the loc of last control" is going to change a layer property.
It doesn't. I guess I misunderstand what you are trying to do.
You said you wanted to set the pointer to the loc of the most recent control, which is created by the user. My only point was one way to do that. Relayering is not required.
It is is another matter entirely to include that control in the group. If other actions create, say, other controls in other groups, then certainly managing the members of each group is important.
Craig
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 9:59 pm
by richmond62
You could have a list field where each line contains the name of an object within a group:
new ones being added at the start of the list.
Then you could have a script that set the object in line 1 of your list to the top layer inside your group.
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 10:06 pm
by DR White
Thanks everyone for all the good suggestions, but they seem like too much work.
I think I will just keep deleting the pointer group and then coping it back after
new control is copied to keep it on top layer.
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 10:42 pm
by SparkOut
Ahem...
A closer look at RELAYER in the dictionary will show you that you can
Code: Select all
relayer <objectref> to front of group <groupref>
(or to back, to put it to the lowest layer of the group)
You can deal with nesting of groups by including "the owner" as a self-reference
Code: Select all
relay me to front of the owner of me
will set the layer to the topmost layer of the group it is in, without bleeding into any other nested groups.
A bit more discussion is here:
https://forums.livecode.com/viewtopic.php?f=9&t=31153
Re: Can LC set an objet to the top laye of a group with script?
Posted: Mon May 25, 2020 11:38 pm
by DR White
SparkOut,
WOW!
The code "relayer <objectref> to front of group <groupref>" works Great!
Thanks SO MUCH,
David