Control ID problem

Peter Haworth pete at mollysrevenge.com
Fri Mar 25 17:27:38 EDT 2011


Thanks.  Yes, the long ID would be best - I wrote this code not long after starting to use LC and before I understood all the ramifications of IDs, layers, etc!  I guess I'll go back and change all the calls to the function to pass the long ID instead of the short one.

I'm still somewhat puzzled by this though.  The value of the defaultStack property is correct right before the line that causes the error (I'm not setting it in my code, it's whatever LC put in there) so It's unclear as to why the error occurs.  While waiting for ideas on this, I changed the code to refer to "control ID pid of stack the defaultStack" and that worked.  On the face of it, it seems that the defaultStack setting isn't always taken into account unless specifically referred to like that.  I'm tempted to report this as a bug? 

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
>>> 
>>> 
>>> 
>>> Recently, Peter Haworth wrote:
>>> 
>>>> I have a function that returns information about a control which takes the
>>>> control's short ID as a parameter. This has been working fine for a long
>>>> time
>>>> but has suddenly started to throw a run time error for one specific control.
>>>> 
>>>> The statement "put the short name of control ID pid into myControlName"
>>>> where
>>>> id is the parameter containing the ID returns the error "No such Object near
>>>> "1076" (1076 is the control ID in pid).
>>>> 
>>>> I can clearly see in the application browser and Inspector dialog that there
>>>> is a button with ID 1076 in a substack of the main stack.  If I use the
>>>> message box to execute "put the short name of control ID 1076", I get the
>>>> same
>>>> error.  But if I execute "put the short name of control ID 1076 of stack
>>>> <mysubstackname>", I get the correct result.
>>>> 
>>>> According to the dictionary, the ID of a control is unique within a main
>>>> stack
>>>> so I can't figure out why this doesn't work without qualifying the ID with
>>>> the
>>>> substack name.  I tried putting an "answer information" right before the
>>>> offending line to display the defaultStack in case something strange was
>>>> happening to the defaultStack property but it is set to the correct stack
>>>> name.
>>>> 
>>>> Any ideas?
>>>> 
>>>> 
>>>> Pete Haworth
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription
>>> preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list