Problems with the focusedObject

Graham Samuel livfoss at mac.com
Fri Sep 19 13:08:46 EDT 2008


Ha! The 'cut' command kills the selectedField. If I look at the  
selectedField before the cut, it does give the field ID. Similarly, I  
suspect that if I do a paste, there won't be anything in the  
selectedField until AFTER the paste is done (there certainly isn't  
beforehand). None of this is clear in the RR docs. I would have  
assumed the selectedField would always be non-empty if a field had the  
focus and one could see the cursor flashing in it, but this is too  
simple a view.

So maybe, just maybe, I've cracked it.

I'll report back.

Graham

I just wrote:

> Bonjour Eric
>
> Thanks for the quick reply. Sadly the selectedField returns empty in  
> the circumstances. I do find this very mysterious. For example, if I  
> put some text in a field and invoke my 'cut' menu, which executes  
> this script fragment from the menuPick handler dealing with "Cut":
>
>            cut
>            if clipboardData["text"] is not empty then
>                put the selectedfield
>                ....
>
> The clipboard data can be shown to be as expected (i.e. what was in  
> the field), but the selectedField is just empty.
>
> There must be some way for the handler in the menu to detect what  
> the cut (or paste or clear) operation was operating on, but I can't  
> find it.
>
> Best wishes from la France profonde
>
> Graham
>
> On 1Fri, 19 Sep 2008 15:39:58 +0200, Eric Chatonet <eric.chatonet at sosmartsoftware.com 
> > wrote:
>>
>> Bonjour Graham,
>>
>> May be the selectedField could be your friend?
>>
>> if the selectedField <> empty then put the long name of the
>> selectedField into tSourceField
>>
>> Le 19 sept. 08 à 15:34, Graham Samuel a écrit :
>>
>>> I'm trying to implement a simple Undo for a text entry screen
>>> consisting of a grid of fields acting as cells (not a single table,
>>> but individual fields). To do this, when the user selects say "Cut"
>>> from the available menu, I want to record not only the currently
>>> selected text - no problem - but also the ID (or better, the name)
>>> of the field/cell where the text was before it was cut. However
>>> when I execute a script line like
>>>
>>> put the short name of the focusedObject into lastFieldCut
>>>
>>> the name is that of the underlying card. This doesn't seem to be
>>> what the documentation says is supposed to happen. The
>>> documentation suggests that the underlying card is returned when
>>> nobody has the focus, yet I have seen the cursor blinking just as I
>>> pull down the menu.
>>>
>>> I think that by invoking a menu I somehow have altered the focus,
>>> albeit temporarily.
>>>
>>> Can anyone explain how I can find out which field was in play when
>>> the menu was invoked?
>>>
>>> TIA
>>>
>>> Graham
>>
>> Best regards from Paris,
>> Eric Chatonet.
>



More information about the use-livecode mailing list