The owner of a selected control - a mystery

Richard Gaskin ambassador at fourthworld.com
Sat Feb 21 10:31:38 EST 2015


Graham Samuel wrote:

...
 >   set the selected to empty
 >
 > This last statement resulted in an execution error: “controls don’t
 > have the same owner”.

I get a different error, "can't find object", which I would expected 
because "selected" is an object property, not a global property.

To deselect all objects use "select empty", or loop through all controls 
with something like:

on DeselectAll
   repeat with i = 1 to the number of controls
      set the selected of control i to false
   end repeat
end DeselectAll

"select empty" will probably be much faster, and certainly simpler to type.


 >... if you put
 >
 > put the number of lines of the selectedObject
 >
 > into the message box, you get zilch (actually I think you get the
 > error described earlier, but I can’t see it). But if you put
 >
 >  put the selectedObject into temp
 >  put the number of lines of temp
 >
 > You get an integer, as expected.

This one's a gray area.

The selectedObject resolves to an object reference, so as written it 
seems the engine is attempting to get the number of lines in the object 
itself (the text property) rather than the object reference string.

To force evaluation to operate on the list of objects rather than the 
object itself, using parentheses seems to do the trick:

   put the number of lines of (the selectedObject)

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for Desktop, Mobile, and Web
  ____________________________________________________________
  Ambassador at FourthWorld.com        http://www.FourthWorld.com




More information about the use-livecode mailing list