Control key vs right mouse click: Pros & cons?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Control key vs right mouse click: Pros & cons?
Several of Serendipity Editor's buttons modify their behavior if the control key is down at mouseUp. Since my user interface is point-&-click, it occurs to me that checking for the right mouse button instead of the control key would be more elegant.
Is there a way to determine the mouse's right button status? (I presume there is, but I cannot identify it.)
Any opinions as to which is the better approach?
Is there a way to determine the mouse's right button status? (I presume there is, but I cannot identify it.)
Any opinions as to which is the better approach?
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control key vs right mouse click: Pros & cons?
cardScript [Rocket Science]
Code: Select all
on mouseUp MUP
put ("Mouse button" && MUP) into fld "ff"
end mouseUp
- Attachments
-
- Mousequetier.livecode.zip
- Here's the stack.
- (962 Bytes) Downloaded 114 times
Re: Control key vs right mouse click: Pros & cons?
Hi Rob,
"mouseup" etc. comes with a parameter, the number of the clicked mousebutton!
1 = "normal" click
2 = middle mousebutton, mostly used on 'NIX
3 = RIGHT click
So you could modify the MOUSEUP handlers accordingly:
You get the picture.
Best
Klaus
"mouseup" etc. comes with a parameter, the number of the clicked mousebutton!
1 = "normal" click
2 = middle mousebutton, mostly used on 'NIX
3 = RIGHT click
So you could modify the MOUSEUP handlers accordingly:
Code: Select all
on mouseup tMouseButton
if tMouseButton = 3 then
## RIGHT click, do your thing...
end if
end mouseup
Best
Klaus
Re: Control key vs right mouse click: Pros & cons?
Thanks for showing me how to do this. Before I do it, though, I'm hoping to hear from others about the tradeoffs between using the mouse button or the control key to modify a button's response.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
Re: Control key vs right mouse click: Pros & cons?
Use both. Check the control key and check the mouse button so that either will work.
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Control key vs right mouse click: Pros & cons?
What everyone said.
The biggest difference, if I understand your point, is that using one of the "control" keys is an extra step, that is, it is not just clicking one of the buttons on a mouse. The benefit is, of course, more options, more possibilities.
Craig
The biggest difference, if I understand your point, is that using one of the "control" keys is an extra step, that is, it is not just clicking one of the buttons on a mouse. The benefit is, of course, more options, more possibilities.
Craig
Re: Control key vs right mouse click: Pros & cons?
Now that I've thought about it, I agree...especially in a point-and-click interface.dunbarx wrote: ↑Thu Aug 26, 2021 2:36 amWhat everyone said.
The biggest difference, if I understand your point, is that using one of the "control" keys is an extra step, that is, it is not just clicking one of the buttons on a mouse. The benefit is, of course, more options, more possibilities.
Craig
I will make the change today and try it.
Thanks all,
Rob Cozens dba Serendipity Software Company
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
Manchester, CA USA
Each new generation gives more attention to the man-made world...
and less attention to the world that made man.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control key vs right mouse click: Pros & cons?
Mr Crude Functionalism here asking WTF "elegant" means.Several of Serendipity Editor's buttons modify their behavior if the control key is down at mouseUp. Since my user interface is point-&-click, it occurs to me that checking for the right mouse button instead of the control key would be more elegant.
Surely what is more to the point is end-user ease of use?
I always have a sneaking suspicion that putting code "elegance" first is a bit like playing with your wobbly bits in private,
while end-user ease of use really is of more lasting value . . .
Of course if one can manage end-user ease of use while using elegant code: go for it.
It is dead-easy to check if the CTRL key is down . . .
Let's have a "hot and sweaty fantasy" with some fairly random code:
Code: Select all
on mouseUp MUP
if controlKey() is down then
if MUP >2 then
put "Well I never, the controlKey is down and you pressed the right button on your mouse"
end if
end if
end mouseUp
Re: Control key vs right mouse click: Pros & cons?
On the face of it a simple question - but some clarification is needed.
- Are you trying to react to a right-click?
- Or are you checking to see if the control key is pressed, eg a control-right-click as well?
(keeping in mind that on Mac the effect control-left-click is equivalent to a right-click, but probably not on any other platform).
If just checking for 'right-click' then i would agree with Klaus that checking for the button parameter = 3 is the better option. Most mouse handlers include a parameter that provides you with an integer 1, 2 or 3 corresonding to the left, middle or right mouse button, to tell you which was clicked.
On Mac, control-left click sets this to 3, i.e. a right mouse click, hence Klaus' example:
The reason this is more 'elegant' is that that it covers both right-clicking and control-left-clicking (on Mac), if that is your desired action.Klaus wrote: ↑Wed Aug 25, 2021 8:59 pmCode: Select all
on mouseup tMouseButton if tMouseButton = 3 then ## RIGHT click, do your thing... end if end mouseup
However, if you are not intending to do a 'right-click' with the control-mouseUp and if your target is not mac, or indeed if you want to do a control-right-click etc, then you can check controlKey() as Richmond recommends.
Hope that makes sense
Stam
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control key vs right mouse click: Pros & cons?
On Macintosh a mouse left-click with the CTRL key depressed
gives you the same contextual menu that you get from a
mouse right-click.
In the FINDER at least.
HOWEVER, for the sake of argument, in this textField that I am currently writing into [Browser = Brave].
a mouse right-click gives me a contextual menu, but a mouse left-click with the CTRL key depressed does
NOT work BECAUSE I have chosen to swap my COMMAND and CTRL keys in the system settings:
- -
As a programmer has no idea about how an end-user has mucked around with their keyboard settings
I would tend to use mouse button 3 instead of leveraging the CTRL key.
gives you the same contextual menu that you get from a
mouse right-click.
In the FINDER at least.
HOWEVER, for the sake of argument, in this textField that I am currently writing into [Browser = Brave].
a mouse right-click gives me a contextual menu, but a mouse left-click with the CTRL key depressed does
NOT work BECAUSE I have chosen to swap my COMMAND and CTRL keys in the system settings:
- -
As a programmer has no idea about how an end-user has mucked around with their keyboard settings
I would tend to use mouse button 3 instead of leveraging the CTRL key.
Re: Control key vs right mouse click: Pros & cons?
Remapping the command and control keys doesn't mean the 'control key' won't work. It just means the key labelled as control is actually mapped to the command key.
Depressing the Command key which has been remapped to the control key will achieve he same effect as clicking control-mouseUp on an unmodified system, because your app doesn't care about your key remapping; it just receives the control and mouseUp events.
Equally i can remap my left and right mouse buttons. If i do this, it should make sense to expect a right click when click the left mouse button, but from my app point of view mouseButton = 3 would then correspond to the left mouse button.
The real question is what the OP is intending to do. I suspect it's just simulating a right-click on 1-button mice, in which case checking for mouseButton = 3 is the safest option that covers all options.
If on the other hand the intention is to check for the control key no matter what mouse button is clicked (for example, if the author wants to react to control-right-click) then that requires checking controlKey() as well.
Depressing the Command key which has been remapped to the control key will achieve he same effect as clicking control-mouseUp on an unmodified system, because your app doesn't care about your key remapping; it just receives the control and mouseUp events.
Equally i can remap my left and right mouse buttons. If i do this, it should make sense to expect a right click when click the left mouse button, but from my app point of view mouseButton = 3 would then correspond to the left mouse button.
The real question is what the OP is intending to do. I suspect it's just simulating a right-click on 1-button mice, in which case checking for mouseButton = 3 is the safest option that covers all options.
If on the other hand the intention is to check for the control key no matter what mouse button is clicked (for example, if the author wants to react to control-right-click) then that requires checking controlKey() as well.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control key vs right mouse click: Pros & cons?
I know that, and you know that, BUT does the average end-user know that, and is the keyboard remappingIt just means the key labelled as control is actually mapped to the command key.
on Macintosh consistent across all applications?
Re: Control key vs right mouse click: Pros & cons?
Not questioning your knowledge, only responding to your post.
Apps do not remap function keys on Mac. It is a very safe bet to assume command, option(alt), control and shift keys will always do what it says on the tin, unless the end user makes a non-trivial effort to change this.
One would assume if an end-user undertakes this quite uncommon practice then they should be aware of the consequences.
If not, they shouldn't be screwing with their system (life lesson right there...)
Apps do not remap function keys on Mac. It is a very safe bet to assume command, option(alt), control and shift keys will always do what it says on the tin, unless the end user makes a non-trivial effort to change this.
One would assume if an end-user undertakes this quite uncommon practice then they should be aware of the consequences.
If not, they shouldn't be screwing with their system (life lesson right there...)
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control key vs right mouse click: Pros & cons?
Pause for muffled chuckles.simulating a right-click on 1-button mice
I thought I was being "no end of posh", when, in 1996 I bought a 3 button
mouse and connected it to my Performa 5200 LC running macOS 8.5 that I had
just bought in downtown Jeddah, KSA.
But this was mainly being bogged down in Saudi Arabia without any internet or any other
way of knowing what on earth was happening in the rest of the world, I hadn't the foggiest
that my adoption of a multi-button mouse was way behind the curve.
So, who is using a single-button mouse these days?
- -
Already outdated before it was released.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Control key vs right mouse click: Pros & cons?
Dunno how uncommon: certainly a lot of people I know who work with computers running Linux, Windows and Macintoshthis quite uncommon practice
find swapping the COMMAND and CTRL keys on a Mac, so things are fairly consistent with Linux and Windows, is a great
boon to productivity, and cuts down on the cursing considerably.
Life lesson there.