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 » Sat Jul 13, 2013 10:31 am

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: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: forcing a group to stay at layer top

Post by Klaus » Sat Jul 13, 2013 10:46 am

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: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: forcing a group to stay at layer top

Post by dunbarx » Sat Jul 13, 2013 2:57 pm

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: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: forcing a group to stay at layer top

Post by Klaus » Sat Jul 13, 2013 3:01 pm

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: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: forcing a group to stay at layer top

Post by dunbarx » Sat Jul 13, 2013 4:16 pm

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 » Sat Jul 13, 2013 4:18 pm

perhaps:

Code: Select all

on create new control
set the layer of the last control to (the layer of group "theTopMost" -1)

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

Re: forcing a group to stay at layer top

Post by Klaus » Sat Jul 13, 2013 4:35 pm

SteveTX wrote:perhaps:

Code: Select all

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

Post Reply