Page 1 of 1

select text of me (field) not working?

Posted: Fri Jan 02, 2015 4:50 pm
by snm
I have new stack with only 1 field with script from copied from dictionary:

Code: Select all

on openField
  select text of the target 
  -- This is not working also:
    -- select text of me
    -- select char 1 to -1 of the target
end openField
After click on the field the text blinks for a moment as selected and loosing selection immediately.
What is strange, when coming back from another stack field is focused for a moment, then out of focus but text is selected.

With this script in the field it works as expected:

Code: Select all

on openField
  send "selectText" to me in 1 tick
end openField

on selecttext
  select text of me
end selectText
Is it a bug?
Yosemite & LC 7.0.1

Marek

Re: select text of me (field) not working?

Posted: Fri Jan 02, 2015 9:28 pm
by Mark
Hi,

The field not being focused while the text is still selected could be a bug, but I'm not sure.

The text not being selected after clicking in a field and running an openField handler is no bug. Think of the order in which things are handled: 1) user clicks, 2) the openField handler runs and 3) the engine handles the click and updates the interface. Since (3) comes after (2), the engine deselects the text and positions the text insertion point at the location of the mouse click. To work around the engine's behaviour, you need to use the "send in <time>" command, which is what you did.

Kind regards,

Mark

Re: select text of me (field) not working? [SOLVED]

Posted: Fri Jan 02, 2015 9:49 pm
by snm
Thanks a lot Mark. I saw it - blinking selection means that some next message clear the selection after openField (it was mouseDown and mouseUp). It should be mentioned in example of use openField message in the Dictionary.

Marek