Control ID problem - even stranger

Scott Rossi scott at tactilemedia.com
Fri Mar 25 19:30:07 EDT 2011


Peter:

The expression "same stack" is key here.  Substacks of a main stack are not
the same stack.  This is easy to test:  create a new stack, add some
substacks to it.  If you drag a button into each of the substacks, the ID of
each button should be 1004, and control ID numbering will start from that
point, within each stack.

This is why it's good to reference long IDs of controls, and make sure your
stacks have unique names.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design





Recently, Peter Haworth wrote:

> While looking into this further, I have discovered what I think is another
> anomaly.  I have two substacks of the same main stack with one card in each
> one.  Each card has one group on it - the two groups have the same short ID.
> 
> The dictionary says that IDs "are guaranteed to be unique within a stack" - I
> had assumed that no two controls within the same stack file could have the
> same ID but either that's not true or there's a bug somewhere that caused
> these two groups to have the same ID.
> 
> At this point, I think I will delete all these substacks and start over to see
> if I still get the same issues.  This is a test stack so not that many
> controls on them.
> 
> Pete Haworth
> 
> On Mar 25, 2011, at 1:52 PM, Scott Rossi wrote:
> 
>> Yes, setting the defaultStack to the name of the substack *should* work.
>> You may want to check that you're not inadvertently setting focus back to
>> the main stack somewhere in your scripts.
>> 
>> Unless you're constantly changing stack names for some reason, IMO, you're
>> better off using the long ID of the control.  That way you don't have to
>> worry about which stack is active or trying to qualify paths.  Don't build
>> the control's path yourself, just store the long ID of the control in a
>> custom property of the main stack for example (ie the myImportantControl of
>> this stack).  That way everything in your stacks will know where the control
>> is.
>> 
>> Regards,
>> 
>> Scott Rossi
>> Creative Director
>> Tactile Media, UX Design
>> 
>> 
>> Recently, Peter Haworth wrote:
>> 
>>> Thanks Scott, that's a possibility, the stack in question is not the
>>> "front-most" one for sure.  However, shouldn't the defaultStack property
>>> (which is set to the correct substack) taken care of that?  Or is there some
>>> other property I can use to qualify the ID?  Since this is a general purpose
>>> handler that could be called from anywhere in my app, I can't hard code a
>>> stack name in it
>>> 
>>> Thanks,
>>> Pete Haworth
>>> 
>>> On Mar 25, 2011, at 1:22 PM, Scott Rossi wrote:
>>> 
>>>> The only thing I could guess is your substack is not the top stack.  I
>>>> don't
>>>> believe LC has ever known to automatically look in substacks for the
>>>> existence of controls.  LC can have multiple stacks open simultaneously,
>>>> and
>>>> can have controls of the same ID in different stacks, so unless the stack
>>>> with your desired control is front-most, or you use a full stack path, LC
>>>> won't know where your control is.
>>>> 
>>>> Regards,
>>>> 
>>>> Scott Rossi
>>>> Creative Director
>>>> Tactile Media, UX Design






More information about the use-livecode mailing list