Lazarus

Programming => Widgetset => Cocoa => Topic started by: Key-Real on September 27, 2022, 03:15:20 pm

Title: How to set Capslock or ScrollLock or NumLock under macOS
Post by: Key-Real on September 27, 2022, 03:15:20 pm
Hi,
how can I toggle Capslock or ScrollLock or NumLock under MacOS?
Title: Re: How to set Capslock or ScrollLock or NumLock under macOS
Post by: KodeZwerg on September 27, 2022, 03:33:27 pm
May I ask for what purpose?
I would be very confused if an application change my System (Keyboard is part of my system)
Maybe there is a better solution if you describe what you aim for?
Title: Re: How to set Capslock or ScrollLock or NumLock under macOS
Post by: Key-Real on September 27, 2022, 07:58:43 pm
I need to perform an action on pressing the CapsLock Key.

If I press it, the keyboard NSKeyDown event came. The LED on this key light up.
I have a boolean buffer for the whole keyboard. It stores if a key is pressed or not.

He trows me that CapsLock is pressed the whole time(no KeyUp event).

So I need to set the CapsLock off. So he can perform the NSKeyUp.


Code: Pascal  [Select][+][-]
  1.      case myType of
  2.           NSKeyDown : if event.keycode < 256 then keyboard[event.keycode]:=true;
  3.           NSKeyUp : if event.keycode < 256 then keyboard[event.keycode]:=false;
  4.           NSFlagsChanged : if event.keycode < 256 then keyboard[event.keycode]:=not keyboard[event.keycode];
  5.           NSLeftMouseDown: mouseL:=true;
  6.           NSRightMouseDown: mouseR:=true;
  7.           NSLeftMouseUp: mouseL:=false;
  8.           NSRightMouseUp: mouseR:=false;
  9.           NSScrollWheel : mouseWheel:=round(event.deltaY);
  10.       end;
  11.  

Or you knew a better solution?

AND (as we are at this topic)
If I press CapsLock very shortly nothing happens. We waits a little time before raise the event(the LED goes on).
How to get rid of this delay?
TinyPortal © 2005-2018