select text of me (field) not working?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

select text of me (field) not working?

Post by snm » Fri Jan 02, 2015 4:50 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

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

Post by Mark » Fri Jan 02, 2015 9:28 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

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

Post by snm » Fri Jan 02, 2015 9:49 pm

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

Post Reply