Puzzling about 'the focusedObject'

Graham Samuel livfoss at mac.com
Tue Dec 10 17:16:15 EST 2013


I'm trying to find out which field (if any) in a set of stacks has the focus (if the object with the focus is not a field I have other actions to perform which are not relevant to this issue). There is a main stack with one card and some fields; and a set of palettes. Some of these palettes have fields. The following script fragment works if the field with the focus is in the main stack:

if the focusedObject contains "field" then
  select the text of the focusedObject
  [...]

This seems a nice, robust idea. But if I open a palette and see a flashing cursor in a field, that bit of code doesn't work because 'the focusedObject' refers to the last field to have the focus in the card in the mainstack.

So, either I've misunderstood the idea of 'the focusedObject' or it doesn't work for palettes. The second conclusion would be odd, since 'copy', 'paste' and 'cut' all work for fields in palettes, without the need to script anything apart from the single command, so the engine certainly knows that the focus is in a field in a palette. How do these commands know where they are supposed to do the cutting or whatever and yet I don't? I can't think of a way of looking this up in the documentation, so I am stuck. By the way this is just to implement a very simple 'select all' menu item.

TIA

Graham






More information about the Use-livecode mailing list