Lazarus

Programming => Widgetset => Cocoa => Topic started by: apeoperaio on December 15, 2022, 02:57:39 pm

Title: Screen.Cursor does not work as expected
Post by: apeoperaio on December 15, 2022, 02:57:39 pm
I encountered an issue related to Screen.Cursor on macOS Ventura (13.0.1):
Lazarus 2.2.5 (rev lazarus_2_2_4-3-g564e1e8244) FPC 3.2.0 x86_64-darwin-cocoa

Setting the cursor using Screen.Cursor does not always work.
You can reproduce the issue using the attached project.
This test project includes a single form with a custom control and a button. The OnClick events of the button and the custom control just switch Screen.Cursor between crDefault and crHourglass.
Code: Pascal  [Select][+][-]
  1.  
  2. if Screen.Cursor = crHourGlass then
  3.     Screen.Cursor:= crDefault
  4.   else
  5.     Screen.Cursor:= crHourGlass;
  6.  

The previous code works on windows but not on macOS (Ventura), after the first click the cursor is set to crHourglass, but if I click again the Cursor still remains crHourglass.

I tested it on 2 different computers, both with macOS Ventura, I cannot test it on previous macOS versions.

Am I doing something wrong?
Title: Re: Screen.Cursor does not work as expected
Post by: apeoperaio on December 16, 2022, 02:46:24 pm
Maybe related to this closed issue?
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/20313
Title: Re: Screen.Cursor does not work as expected
Post by: han on December 29, 2022, 09:25:44 pm
I have the same problem with my application. It works under Big Sur but not under Ventura. I can't test it because I only have Big Sur but it was reported by users. Does the following instruction help??:

form1.cursor:=crDefault;

Han
Title: Re: Screen.Cursor does not work as expected
Post by: han on December 29, 2022, 09:47:33 pm
The test application works on Big Sur. Both the form and button allow to toggle between normal and wait cursor.

Han
Title: Re: Screen.Cursor does not work as expected
Post by: apeoperaio on December 30, 2022, 10:00:54 am
Does the following instruction help??:

form1.cursor:=crDefault;

Han

Tested, but it does not work
Title: Re: Screen.Cursor does not work as expected
Post by: KodeZwerg on December 30, 2022, 11:34:32 am
You could probably do something like
Code: Pascal  [Select][+][-]
  1. var
  2.   LCursor: TCursor;
  3. begin
  4.   LCursor := Screen.Cursor;
  5.   Screen.Cursor := crHourGlass;
  6.   // do your stuff
  7.   if Screen.Cursor = crHourGlass then
  8.     Screen.Cursor := LCursor;
  9. end;
Title: Re: Screen.Cursor does not work as expected
Post by: wp on December 30, 2022, 12:40:59 pm
I have an OS X 10.14.3 on a VM, and here the cursor toggles correctly with each button click.
Title: Re: Screen.Cursor does not work as expected
Post by: han on January 02, 2023, 02:57:30 pm
I have created a bug report for this and attached the test program:

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40078

KodeZwerg,
I  can't test your proposal because I personally don't have Ventura. But I don't see why why this would help.  The instruction Screen.Cursor:= crDefault should do the trick without exception.

Wp,
Based on my program users response. I assume it is only related to Ventura.

Han

Title: Re: Screen.Cursor does not work as expected
Post by: apeoperaio on January 03, 2023, 03:11:18 pm
I have created a bug report for this and attached the test program:

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40078

Thank you
Title: Re: Screen.Cursor does not work as expected
Post by: han on June 10, 2023, 05:50:29 pm
There is now a bug fix. I haven't Ventura. Can somebody confirm it also works for him/her?


Quote
Cursor completely refactored on MacOS.
the issue should be fixed by d27f5e3e.
test it please.

https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/d27f5e3e4b37fb0b922a7cb9cb8371ef0e0dbfea
Title: Re: Screen.Cursor does not work as expected
Post by: apeoperaio on June 12, 2023, 01:20:18 pm
Tested on Ventura (Version 13.4) and now it works. Both x86_64 and aarch64.
The issue can be closed. Thank you.

Lazarus 2.3.0 (rev main-2_3-3655-g3a096be5) FPC 3.2.2 aarch64-darwin-cocoa
TinyPortal © 2005-2018