Recent

Author Topic: [SOLVED] Cocoa TStatusBar bug  (Read 2313 times)

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
[SOLVED] Cocoa TStatusBar bug
« on: December 13, 2019, 11:50:47 pm »
I have not yet been able to reproduce this bug in a simple program in order to file a bug report, but would like to know if anyone has observed similar behavior.

I have a TStatusBar on a form that reports coordinates on TPaintBox MouseMove events. After opening and dismissing a modal dialog, the TStatusBar stops displaying the text updates. Clicking on the desktop, and then back on the form, fixes it.

This does not occur on Windows or Linux.

Has anyone noticed similar behavior?
« Last Edit: January 04, 2020, 04:55:30 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

winni

  • Hero Member
  • *****
  • Posts: 722
Re: Cocoa TStatusBar bug
« Reply #1 on: December 14, 2019, 12:59:43 am »
Hi!

Focus lost??

Winni

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #2 on: December 14, 2019, 01:06:24 am »
Thanks, nope. Checked that.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

winni

  • Hero Member
  • *****
  • Posts: 722
Re: Cocoa TStatusBar bug
« Reply #3 on: December 14, 2019, 01:23:09 am »
Hi!

ImageOnExit
PaintBoxOnExit triggered??

Winni
« Last Edit: December 14, 2019, 01:24:43 am by winni »

winni

  • Hero Member
  • *****
  • Posts: 722
Re: Cocoa TStatusBar bug
« Reply #4 on: December 14, 2019, 01:35:10 am »
Hi!

Or hardrock check:

Use a timer. On the timer event do a

x := Mouse.CursorPos.x
y := Mouse.CursorPos.y

and draw x and y on the toolbar.

So you can check if it is only a PaintBox problem or if there is a deeper problem.

Winni

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2347
    • havefunsoft.com
Re: Cocoa TStatusBar bug
« Reply #5 on: December 14, 2019, 01:36:13 am »
After opening and dismissing a modal dialog, the TStatusBar stops displaying the text updates. Clicking on the desktop, and then back on the form, fixes it.
it sounds like the modal dialog is being closed by the mouse click.
(meaning that the mouse remains "locked up" by a control on the closed dialog)
The remedy is just to make another click (mouse-up releases the lock).

Here's what you can do - try to close the modal window by other means than the mouse (keyboard, obviously)
and check if you're getting mouseMove events or not.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #6 on: December 14, 2019, 02:39:16 am »
After opening and dismissing a modal dialog, the TStatusBar stops displaying the text updates. Clicking on the desktop, and then back on the form, fixes it.
it sounds like the modal dialog is being closed by the mouse click.
(meaning that the mouse remains "locked up" by a control on the closed dialog)
The remedy is just to make another click (mouse-up releases the lock).

Here's what you can do - try to close the modal window by other means than the mouse (keyboard, obviously)
and check if you're getting mouseMove events or not.

Thanks. I'll give that a shot, but the MouseMove event is getting through. TStatusBar is definitely getting the text:

  StatusBar1.Panels[0].Text := s;

The test is sent, but not displayed.

I can close the dialog by pressing enter, and there is no change in behavior.

Again, clicking on the desktop, and then back on the form fixes it.
« Last Edit: December 14, 2019, 02:53:54 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #7 on: December 14, 2019, 08:37:29 pm »
I think winni was on the right track. I had checked focus for the form, but not the statusbar. This seems to work:

Code: Pascal  [Select]
  1.  
  2.   {$IFDEF DARWIN}
  3.   StatusBar1.SetFocus;
  4.   {$ENDIF}
  5.   StatusBar1.Panels[0].Text := s;
  6.  

Thanks! :)

I still have not been able to create a simple demo that reproduces it though.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2347
    • havefunsoft.com
Re: Cocoa TStatusBar bug
« Reply #8 on: December 15, 2019, 07:45:28 pm »
statusbar getting focus is a very exotic approach.
i'd think you're not looking for the status bar to get focus.

instead you're getting mouse position globally and updating the status bar
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #9 on: December 15, 2019, 10:11:34 pm »
statusbar getting focus is a very exotic approach.
i'd think you're not looking for the status bar to get focus.

instead you're getting mouse position globally and updating the status bar

Thanks, that is what I am trying to do.

The mouse position is gotten on mousemove (this works fine).
The coordinates are converted into a string (this works fine).
The statusbar is updated to display the string (this does not work).

When debugging, I can see that the string is correct when assigned to statusbar.panels[0].text. The statusbar, however, does not display anything. It works fine in Windows and Linux. If I set the focus, it also works on Mac. I'd be happy to know of a better solution.

The statusbar works fine until I display a modal dialog and dismiss it. Then it stops working. If I switch to the Finder or another program, and back, it starts working again. I will try again to write an example program displaying the issue.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2347
    • havefunsoft.com
Re: Cocoa TStatusBar bug
« Reply #10 on: December 17, 2019, 05:57:30 am »
there were some changes in the trunk regarding switching the modal window
please see if it works now w/o the explicit SetFocus method
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #11 on: January 01, 2020, 11:21:06 pm »
Many thanks. Unfortunately, I just tried trunk and there is no change in the behavior.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2347
    • havefunsoft.com
Re: Cocoa TStatusBar bug
« Reply #12 on: January 02, 2020, 12:45:01 am »
need a sample
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #13 on: January 02, 2020, 05:26:26 am »
Thanks, I understand. I will try to provide one.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Cocoa TStatusBar bug
« Reply #14 on: January 03, 2020, 08:03:30 pm »
This was tricky to isolate. The call to ShowModal was a red herring, and a TLabel shows the same behavior as TStatusBar.

However, adding a control to the form that takes focus, such as a TButton or TEdit fixes the problem. The attached program shows this.

Click on the desktop and then on Form1 to get the controls working.

In the mean time this is my workaround:

Code: Pascal  [Select]
  1. procedure TPlotForm.FormActivate(Sender: TObject);
  2. begin
  3.   {$IFDEF DARWIN}
  4.   StatusBar1.SetFocus; // Cocoa bug workaround
  5.   {$ENDIF}
  6. end;

VTwin

EDIT: Wrong file uploaded, see next post.
« Last Edit: January 03, 2020, 08:54:26 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4