set the layer of a control to the top of a group

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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

set the layer of a control to the top of a group

Post by jmburnod » Sat Mar 02, 2013 12:07 pm

Hi All
i want set the layer of a control to the top of a group

The doc say that is not possible to set the layer of a control of a group to the top of the group

Delete/create this control is the only way i found :oops:

Does someone have a trick to avoid this

Best regards
Jean-Marc
https://alternatic.ch

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: set the layer of a control to the top of a group

Post by Klaus » Sat Mar 02, 2013 1:55 pm

Hi Jean-Marc.

this IS indeed possible, but at your own risk :D
...
set the relayerGroupedControls to TRUE
## do your relayer stuff here and now...
...


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: set the layer of a control to the top of a group

Post by bn » Sat Mar 02, 2013 8:40 pm

Hi Jean-Marc,

as Klaus said it is a bit risky to fool around with the layer of a grouped control: you can easily "layer it out of the group".
But if you are careful it is ok. Just know what your are doing.

For me this works very well, maybe someone has an easier way.
for testing I made a group from a bunch of overlapping buttons. The buttons don't have any script, especially not a mouseDown handler
put this script into the group

Code: Select all

on mouseDown
   set the relayerGroupedControls to true
   put empty into tLayers
   repeat with i = 1 to the number of controls of me
      put the layer of control i of me & comma after tLayers
   end repeat
   delete last char of tLayers -- a comma
   put max (tLayers) into tMaxLayer
   
   set the layer of the target to tMaxLayer
   set the relayerGroupedControls to false -- important
end mouseDown
it will bring the button you click to the front.

Kind regards
Bernd

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: set the layer of a control to the top of a group

Post by jmburnod » Sun Mar 03, 2013 2:43 pm

Hi Dears,

Thank one more for help
The Bernd' script work like a charm in a simplified stack i build but not yet in my context. I think i shoot my foot somewhere.

Kind regards
Jean-marc
Attachments
SetLayercontrolInGroup.livecode.zip
(31.53 KiB) Downloaded 296 times
https://alternatic.ch

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: set the layer of a control to the top of a group

Post by splash21 » Sun Mar 03, 2013 6:45 pm

If you add an invisible control to the group in the topmost position, (example : a graphic called 'topGraphic'), you can then;

set the relayerGroupedControls to true
set the layer of object "MyObject" to the layer of graphic "topGraphic"

This prevents you accidentally displacing 'MyObject'.
LiveCode Development & Training : http://splash21.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: set the layer of a control to the top of a group

Post by jmburnod » Sun Mar 03, 2013 7:13 pm

Hi Splash,
Thanks
That is a clever way but only for a group without adding controls

I think the Bernd's way is good.
It is just a dirty solution I have to solve

Best regards
Jean-Marc
https://alternatic.ch

david.silmanBUSrUeQ
Posts: 44
Joined: Thu Jul 19, 2012 1:49 pm

Re: set the layer of a control to the top of a group

Post by david.silmanBUSrUeQ » Wed Mar 13, 2013 2:54 pm

Hi jmburnod

We've had to do a lot of relayering in the program we're making, if you're just moving a control to the top of a group then here is a simpler way to do it:

Code: Select all

start editing me #or whatever the group is called
set the layer of control <name of control> to top
stop editing
we've found that to be the best way of doing it without any worry of displacing the control out of the group

David

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: set the layer of a control to the top of a group

Post by jmburnod » Wed Mar 13, 2013 5:40 pm

Hi David,

Thanks for this hit
I tested it in my context and it work fine
I noticed delete all controls of the group and rebuild it is a bit faster (25%) than editing background way
What is the better way for the processor ?
Best regards
Jean-Marc
https://alternatic.ch

Post Reply