Recent

Author Topic: detecting Command Click  (Read 1872 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
detecting Command Click
« on: August 13, 2020, 09:20:04 am »
Please help a Mac-a-phobe.

In my app, a right click pops up a menu.   But on the Mac, there is no right click and by convention, users hold the Command Key down and then click with the poor crippled mouse they use. 

But the OnClick event does not tell me the state of the keyboard, seems I need to detect a key-down event, if its the Command key set a boolean and then if I detect a key-up event, if its the Command key unset that boolean.

If the use clicks while that boolean is set, its a command click - wow, is there an easier (and less obtrusive for non Mac) way to do it ?

Would be better to look to see if the command key is down at the time of a click but that does not seem possible to me ....

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: detecting Command Click
« Reply #1 on: August 13, 2020, 09:41:48 am »
CTRL-click = Right click (to get, eg, a context menu).

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: detecting Command Click
« Reply #2 on: August 13, 2020, 10:43:54 am »
Yeah, of course !  Thanks Trev !

Code: Pascal  [Select][+][-]
  1. if {$ifdef DARWIN} (ssCtrl in Shift) {$ELSE} (Button = mbRight) {$ENDIF}

Interesting it should be Control not the Command I thought ......

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: detecting Command Click
« Reply #3 on: August 13, 2020, 11:05:03 am »
Macos supports right click, do this or say the user:
Hold [ctrl]-Key + Mouse Button left click = Mouse button right click.

You have not to change your application code.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: detecting Command Click
« Reply #4 on: August 17, 2020, 01:03:32 am »
But on the Mac, there is no right click and by convention, users hold the Command Key down and then click with the poor crippled mouse they use.

They have had right clicks, and more, for over a decade:

https://support.apple.com/en-gb/HT204895

https://en.wikipedia.org/wiki/Magic_Mouse

« Last Edit: August 17, 2020, 02:56:04 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018