Selecting text in a field with script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Selecting text in a field with script

Post by sritcp » Wed Jun 12, 2019 3:08 pm

I have a regular text field (not list field).
When I type in the message box

Code: Select all

select word 5 of field 1
nothing happens! (well, sometimes the word gets highlighted for a split second).

Is it not possible to select text by script in an editable text field?

Thanks,
Sri

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Selecting text in a field with script

Post by dunbarx » Wed Jun 12, 2019 3:21 pm

Confirmed here from the message box in both v.8 and v.9.

But works fine in a button script.

Craig

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Selecting text in a field with script

Post by sritcp » Wed Jun 12, 2019 4:21 pm

Craig:

Something to do with the currently active window being the Message Box, not the card with the field.

Create Button1 with the script

Code: Select all

on mouseUp
   selectWord
end mouseUp

command selectWord 
   select word 3 of field "Field1" of this card
end selectWord
Now, from msg
send "selectWord" to button "Button1"
doesn't work.
Neither does
send "mouseUp" to button "Button1"
But, clicking on Button1 does work.

Regards,
Sri

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Selecting text in a field with script

Post by dunbarx » Wed Jun 12, 2019 6:01 pm

Sri.

Sort of.

If, in msg, I give an explicit stack reference:

Code: Select all

select word 2 of fld 1 of stack "untitled 1"
I get the flash selection you mentioned, that very soon disappears.

But if I place a button with that same handler in another stack, it selects just fine in the target stack.

So since the other stack and the message box are both "just" stacks, it is msg that has issues. This has long been known with the message box, and we all live with them.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”