Forum > LCL

[Solved] Cannot detect key[Down|Press|Up] activity in Lazarus on MacOS X 11-14

<< < (2/4) > >>

BradleySlavik:
Now I am seeing new messages.

Warning: ld: warning: -multiply_defined is obsolete
Error: -macosx_version_min has been renamed to -macos_version_min
Warning: ld: warning: ignoring duplicate libraries: '-lc'
Warning: ld: warning: no platform load command found in 'ProjectPath/x86-64-darwin/project1-or', assuming: macOS

The machine that I have not tried to make bundle does not have these errors.

Handoko:
I don't have MacOS computer for testing the code. Anyone have who has MacOS computer please help, the code is here:
https://forum.lazarus.freepascal.org/index.php/topic,42439.msg297949.html#msg297949

@BradleySlavik

The Pong demo I wrote, using GetKeyStated function. Maybe it is not implemented on MacOS or having bug. Alternatively you can use FormKeyDown event, here has a example code of using FormKeyDown:
https://forum.lazarus.freepascal.org/index.php/topic,57229.msg425440.html#msg425440

carl_caulkett:

--- Quote from: Handoko on November 24, 2024, 12:37:58 pm ---I don't have MacOS computer for testing the code. Anyone have who has MacOS computer please help, the code is here:
https://forum.lazarus.freepascal.org/index.php/topic,42439.msg297949.html#msg297949

--- End quote ---

I've just tried it with Lazarus 3.99 (4.99) + FPC 3.3.1 running on macOS 15.1.1 Sequoia. The project builds and runs, but the bat does not respond to any cursor movements.

It seems that GetKeyState is not implemented on macOS. Cmd clicking the GetKeyState function call, just reveals this (non)implementation...

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;begin  Result := 0;end; 
However, your suggestion of using the OnKeyUp and OnKeyDown events works fine!

Handoko:
Thank you for reporting it.
So, GetKeyState is an unimplemented feature in MacOS.

dsiders:

--- Quote from: carl_caulkett on November 24, 2024, 01:20:12 pm ---It seems that GetKeyState is not implemented on macOS. Cmd clicking the GetKeyState function call, just reveals this (non)implementation...

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;begin  Result := 0;end; 
--- End quote ---

TWidgetSet is a base class. The macOS-specific implementation is in:

* lcl/interfaces/cocoa/cocoawinapi.inc
* lcl/interfaces/cocoa/cocoawinapih.inc

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version