why does this not work and how do you do it?

J. Landman Gay jacque at hyperactivesw.com
Thu Apr 10 16:05:13 EDT 2008


Peter Alcibiades wrote:
> OK, this is really simple to do.  You make a new mainstack with one card
> whose script is:
> 
> on mouseUp
> focus on field "Field"
> end mouseUp
> 
> Now you create a button with traversal off and a field with traversal on. 
> The button script is:
> 
> on mouseUp
>   ask "pick a number"
>   if isNumber(it) is true then put it into field "Field"
>   if the result is "Cancel" then select the text of field "Field"
>   if isNumber(it) is false then send mouseUp to this card
> end mouseUp
> 
> Select text as you and Jacque suggested works fine.
> 
> Now, what I expect is that if you enter say xyz at the prompt, it should
> send mouseUp to the card, and this should be exactly the same as clicking on
> the card.  Maybe this is not right?

I think it is not right. :)

When you send a message, like "mouseup", to a card, that is all that 
happens. Just the message. Any user actions that would ensue from a 
physical click don't execute. You only get a message entry lined up in 
the message queue. It's all very silent and behind the scenes.

If you want to simulate a real, physical click, then use "click at 
<locx,locy>" or "click at the loc of fld 1". This duplicates a physical 
user action. It isn't really the best way to go about it though. 
However, the "click at" command sends all the normal mouse messages that 
are associated with a physical click (mousedown, mousestilldown, 
mouseup) and sets the focus.

But a better way is to just script the behaviors you want -- i.e., to 
select the text of the field. Just like you did. :)

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list