Recent

Author Topic: detecting Command Click  (Read 860 times)

dbannon

  • Hero Member
  • *****
  • Posts: 1165
    • 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 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1008
  • 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).
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

dbannon

  • Hero Member
  • *****
  • Posts: 1165
    • 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 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Soner

  • Full Member
  • ***
  • Posts: 195
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: 936
  • 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.0
macOS 10.13.6: Lazarus 2.0.10 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.10 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.10 (64 bit on VBox)

 

TinyPortal © 2005-2018