get the layer of a control within its group

miscdas at boxfrog.com miscdas at boxfrog.com
Wed May 14 15:34:01 EDT 2003


 

> **********
>> Date: Tue, 13 May 2003 23:30:20 -0700 (PDT)
>> From: erik hansen <erikhans08 at yahoo.com>
>> Subject: get the layer of a control within its group
> 
>>  
>> 
>> i am trying to get the layer of a control
>> within its group. the group "Piano" has buttons
>> representing 52 white keys followed by 36 black
>> keys.  
>> 
>> in group editing mode btn "n22" (the lowest black
>> key) has the layer = 53. otherwise the level is
>> given as 125. 
>> 
>> the idea is to determine how to change the
>> appearance of the button when it is clicked on.
>> black and white keys have different behavior. 
>> 
>> i would like to keep all of the buttons in the
>> same group. 88 has a nice heft to it. i could
>> make a list of the 88 ids and determine use
>> itemOffset,
>> but is their an easy way to get the layer of a
>> control relative to its group?
> ----------
=================
Mr. Hansen, 

I suspect you diodn't read the Transcript Dictionary entry for layer. 

"The layer of a group is one less than the layer of the lowest-layered 
object in the group." 

To rephrase, the layer of the lowest layered object in a group is one more 
than the layer of the group. 

So, here is a hand-holding walk-through for you. 

Example:  a group with three buttons. The group layer value is 6. The button 
layer numbers are 7, 8, and 9. 

So, to find the layer value of a control relative to the group, just 
subtract the group layer value from the pertinent control layer value. 


put ( the layer of button "Black1" in group "BlackGroup" ) - ( the layer of 
group "BlackGroup" ) 

Of course you can script a more useful generic handler that requires the 
button and group parameters. 


miscdas



More information about the use-livecode mailing list