Making "Wells": Whose Control Is It Anyway?

Richard Gaskin ambassador at
Tue Feb 22 12:47:15 EST 2005

Jerry Balzano wrote:
> I have a stack where I use grouped objects as “wells” from which users 
> can drag a copy for their own use.  I need to be able to refer to the 
> owner of these grouped objects but it’s also important for the groups to 
> have names.  The copied group has the same name as the original, but 
> this is good, because the name is meaningful.  Anyway, every newly 
> created group has its own distinctive ID, so there should be no problem, 
> right?  Actually, wrong.  If I have a group called “mygroup”, say ID 
> 1004, which I copy and paste to create a new instance of “mygroup”, say 
> ID 1015, my attempts to find out the owner of the objects in the second 
> group always returns the owner of the first group instead.
> In more detail, the original group and its copy both have a popup menu. 
>  I have given the button to whom the “menuPick” message is sent a 
> “whoCalled” custom property, so that it resizes the proper controls 
> depending on which instance was the source of the menu choice.  Here’s 
> my menuPick handler:
> on menuPick theChoice
>   put the whoCalled of me into caller
>   put theChoice into word 1 of fld id caller
>   if theChoice is "towardsxy" then set the width of fld id caller to 188
>   else set the width of fld id caller to 240
>   put the long id of the owner of fld id caller into owningGroup
>   repeat with i=1 to the number of controls of owningGroup
>     get the name of control i of owningGroup
>     if word 1 of it is "group"
>     then set the right of control i of owningGroup to ((the right of fld 
> id caller) - 5)
>     if word 1 of it is "image"
>     then set the left of control i of owningGroup to ((the left of fld 
> id caller) + 4)
>   end repeat
> end menuPick
> (BTW is there not an easier way to get at the elements of a group than 
> this?  I hoped there was, and I was just too dense to figure it out.  If 
> so, please let me know.  Any style tips, I would also be grateful to get.)
> Everything in the handler works just fine until the command
> put the long id of the owner of fld id caller into owningGroup
> What the variable “owningGroup” ends up containing is “Group ID 1004…” 
> (using the same example as above), not “Group ID 1015…”, even when 
> whoCalled is (correctly) referenced as one of the controls in Group ID 
> 1015.
> What can I do about this?

Short term: forget "the owner" and use the long ID instead, dropping the 
part before " group ID ".

Long term:  All object references returned by the engine MUST be in 
their universal ID-based form unless the user specifically requests a 
potentially ambiguous alternative (like "long name").

Therefore I would consider this a bug, and would gladly vote for it in 

  Richard Gaskin
  Fourth World Media Corporation
  Ambassador at

More information about the Use-livecode mailing list