Recent

Author Topic: Screen.Cursor does not work as expected  (Read 4002 times)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 273
Screen.Cursor does not work as expected
« 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?

apeoperaio

  • Sr. Member
  • ****
  • Posts: 273
Re: Screen.Cursor does not work as expected
« Reply #1 on: December 16, 2022, 02:46:24 pm »

han

  • Jr. Member
  • **
  • Posts: 96
Re: Screen.Cursor does not work as expected
« Reply #2 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

han

  • Jr. Member
  • **
  • Posts: 96
Re: Screen.Cursor does not work as expected
« Reply #3 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

apeoperaio

  • Sr. Member
  • ****
  • Posts: 273
Re: Screen.Cursor does not work as expected
« Reply #4 on: December 30, 2022, 10:00:54 am »
Does the following instruction help??:

form1.cursor:=crDefault;

Han

Tested, but it does not work

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2050
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Screen.Cursor does not work as expected
« Reply #5 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;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: Screen.Cursor does not work as expected
« Reply #6 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.

han

  • Jr. Member
  • **
  • Posts: 96
Re: Screen.Cursor does not work as expected
« Reply #7 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


apeoperaio

  • Sr. Member
  • ****
  • Posts: 273
Re: Screen.Cursor does not work as expected
« Reply #8 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

han

  • Jr. Member
  • **
  • Posts: 96
Re: Screen.Cursor does not work as expected
« Reply #9 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
« Last Edit: June 10, 2023, 05:58:21 pm by han »

apeoperaio

  • Sr. Member
  • ****
  • Posts: 273
Re: Screen.Cursor does not work as expected
« Reply #10 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