Page 1 of 1

On MouseUp with a parameter question

Posted: Mon May 29, 2017 2:56 pm
by chipsm
When I use the following code, what actually happens?

This is the code for a button object:

on MouseUp pBtnNum
--answer pBtnNum
if pBtnNum = 3 then answer "ok"
end MouseUp

I am assuming that by adding the parameter pBtn to the “on MouseUp” command that this allows me to access the pBtn in the script.
This parameter is different for buttons vs. fields.

The results were:
Left Click :nothing
Right Click : Message box

This is the script for a field object:
on mouseUp pBtn
answer pBtn
end mouseUp

The results were:
Left Click : nothing
Right Click : message box with the number 3

I am just trying to understand this and I can’t seem to find documentation about this.

Re: On MouseUp with a parameter question

Posted: Mon May 29, 2017 3:02 pm
by Klaus
Hi Chips,

other than buttons and other LC objects, un-locked fields only receive RIGHT-clicks -> pBtn = 3
and no "normal" (left) mouse-messages.


Best

Klaus

Re: On MouseUp with a parameter question

Posted: Mon May 29, 2017 3:14 pm
by chipsm
Thanks Klaus.
When I add a parameter to an object, does this initiate a change in the message path that allows the detection of the parameter?

Re: On MouseUp with a parameter question

Posted: Mon May 29, 2017 3:50 pm
by Klaus
Sorry, no capisce, can you give an example?

Re: On MouseUp with a parameter question

Posted: Mon May 29, 2017 4:44 pm
by dunbarx
Adding parameters to a message does not change the message path. Parameters only carry additional information. The are read by the receiving handler in the order they are passed, usually named (or renamed) at the first line of the handler itself, and used inside that handler from that point on.

So, in the simplest possible case:

Code: Select all

on mouseUp
   double 44
end mouseUp

on double tNumber
   answer tNumber * 2
end double
Craig Newman

Re: On MouseUp with a parameter question

Posted: Mon May 29, 2017 5:02 pm
by chipsm
Thanks Craig.