forcing a group to stay at layer top [solved]

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
SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

forcing a group to stay at layer top [solved]

Post by SteveTX »

I've set a group to layer top, and set the lockLoc of the layer to true. Subsequent controls I create are on top of the desired top group. Is there a way to keep a layer at the top and force new layers to be created underneath without constantly sending set layer messages?
Last edited by SteveTX on Sat Jul 13, 2013 8:01 pm, edited 1 time in total.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: forcing a group to stay at layer top

Post by Klaus »

Hi Steve,

not automatically, you always need to:
...
set the layer of grp "the TOPMOST one" to top
...

On the other hand you could:
...
set the layer of the templateXXX to nnn
## where nnn is a number < the layer of grp "the TOPMOST one"
create XXX
...
8-)


Best

Klaus
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: forcing a group to stay at layer top

Post by dunbarx »

Just another wrinkle on what Klaus suggested, and which is less elegant than what he said but more direct (pseudocode):

on create new control
set the layer of the last control to the number of layers -1

Craig Newman
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: forcing a group to stay at layer top

Post by Klaus »

Hm...

this will fail in this scenario:
top control is a group, which is NOT empty! 8-)
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: forcing a group to stay at layer top

Post by dunbarx »

Klaus.

Shows you what sloppy thinking and zero testing can do for you. Now this (still pseudo):

create new control

set the layer of last control to the layer of the last group - 1 --I have seen more robust code in my day

or

set the layer of last control to 1 --seems narrow minded

Back to the scrabble board.

Craig
SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: forcing a group to stay at layer top

Post by SteveTX »

perhaps:

Code: Select all

on create new control
set the layer of the last control to (the layer of group "theTopMost" -1)
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: forcing a group to stay at layer top

Post by Klaus »

SteveTX wrote:perhaps:

Code: Select all

set the layer of the last control to (the layer of group "theTopMost" -1)
Yes, Sir :-)
Post Reply