What is "pBtnNum"?

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
makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

What is "pBtnNum"?

Post by makeshyft » Wed May 22, 2013 7:31 pm

Hi,

I've come across a couple of sample scripts that use "pBtnNum" in the script. I have force variable declaring on, and the script runs fine, leading me to conclude this is NOT a user variable.

Example script:
on mouseUp pBtnNum
global theChosenColor
if pBtnNum is 1 then
## Prompt user for color using current color as default
answer color with the effective backgroundcolor of me

## If user didn't cancel then assign background color
## to chosen color
if the result is not "cancel" then
put it into theChosenColor
set the backgroundcolor of me to theChosenColor
end if
end if
answer theChosenColor
end mouseUp
What does this refer to?

Thanks
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: What is "pBtnNum"?

Post by FourthWorld » Wed May 22, 2013 7:35 pm

Looking in the Dictionary for the mouseUp message, it says:
Parameters:
The mouseButtonNumber specifies which mouse button was pressed:
* 1 is the mouse button on Mac OS systems and the left button on Windows and Unix systems.
* 2 is the middle button on Unix systems.
* 3 is the right button on Windows and Unix systems and Control-click on Mac OS systems.
http://livecode.com/developers/api/5.0.2//mouseUp/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: What is "pBtnNum"?

Post by makeshyft » Wed May 22, 2013 7:44 pm

Oh Geez... that makes perfect sense....lol. I did a search for it, and nothing came up. Thanks
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: What is "pBtnNum"?

Post by dunbarx » Wed May 22, 2013 9:19 pm

Hi.

But much more importantly, this term, and its name is arbitrary and up to you, is a parameter associated with the message itself. This is a built-in parameter, and though it is not required for the handler to work, it provides additional information to the engine.

There are naming conventions that many here follow, as it helps to have a common lexicon. The "p" is one of those common prefixes. "t" is another for local variables.

But this could have just as well have been:

on mouseUp theButtonYouHeldDown

You will encounter these sorts of things more when you deal with functions, custom functions and custom handlers, where several parameters may be passed along with the message name. When you get the hang of them, they provide enormous power to the language.

Craig Newman

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: What is "pBtnNum"?

Post by Simon » Wed May 22, 2013 11:14 pm

Hi Craig,
Is there a way to show all the passed preferences?
on mouseDown
put the parameters passed --???
end mouseDown
A way to display information (I can see it's in the dictionary) that may get overlooked?

Thanks,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: What is "pBtnNum"?

Post by dunbarx » Wed May 22, 2013 11:36 pm

Simon.

Do you mean something like this? In a button script:

on mouseup
showparams a,b,c
end mouseUp

on showparams
answer the params
end showparams

I still cannot get my "code" helper to work, and I have seen others using it.

Craig

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: What is "pBtnNum"?

Post by Simon » Wed May 22, 2013 11:40 pm

Nice!
Thanks Craig.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply