Puzzling about 'the focusedObject'

Graham Samuel livfoss at mac.com
Wed Dec 11 06:03:06 EST 2013


Thanks Jacque and Craig for your replies.

One of the charms of being an LC developer in the European time zones is that you send your query to the list, go to bed, and find that Jacque has solved the problem while you sleep!

Curiously enough I had started with 'the selectedField', but as my menu deals with non-Field objects as well, I switched to 'the selectedObject' as being more universal, as it were. That's when I found what appears to be an anomaly about palettes (I won't call it a bug in the engine as there may have been some intention there, but if I'm right it's a bug in the Dictionary). I now have to use a combination of the two properties to do what I want.

[I serious point here, but probably needing a quite separate discussion, is the question of how such a topic as "who's got the focus" could and should be tackled in the LC documentation. In the existing User Guide, for example, there's a lot of stuff about text, chunk expressions etc, but AFAIKS this quite fundamental issue isn't discussed. There are lots of topics like that, I find - for example, another one is file handling, with the the two pretty  much overlapping systems ('file' commands and URLs) and in particular what can go wrong. In the URL scheme, how do I know if my read or write has failed? Not much in the docs on that one... anyway this is as I said a digression, but as a topic it does deserve some discussion.]

Thanks again

Graham

On 11 Dec 2013, at 02:12, J. Landman Gay wrote:

> On 12/10/13 4:16 PM, Graham Samuel wrote:
> 
>> 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.
> 
> I always use "the selectedfield". My "select all" menu item has a very short bit of script:
> 
> if the selectedfield <> empty then select the text of the selectedfield
> 
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com

Craig Newman wrote:

> Seems counterintuitive to me; I will play around a bit. But it could be standard behavior.
> 
> But at least you can rewrite your handler to include a test of the owner of the field. If it is a card or group in the mainstack, then do this. Else do that.





More information about the Use-livecode mailing list