Lazarus

Programming => Widgetset => Cocoa => Topic started by: VTwin on December 13, 2019, 11:50:47 pm

Title: [SOLVED] Cocoa TStatusBar bug
Post by: VTwin 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?
Title: Re: Cocoa TStatusBar bug
Post by: winni on December 14, 2019, 12:59:43 am
Hi!

Focus lost??

Winni
Title: Re: Cocoa TStatusBar bug
Post by: VTwin on December 14, 2019, 01:06:24 am
Thanks, nope. Checked that.
Title: Re: Cocoa TStatusBar bug
Post by: winni on December 14, 2019, 01:23:09 am
Hi!

ImageOnExit
PaintBoxOnExit triggered??

Winni
Title: Re: Cocoa TStatusBar bug
Post by: winni 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
Title: Re: Cocoa TStatusBar bug
Post by: skalogryz 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.
Title: Re: Cocoa TStatusBar bug
Post by: VTwin 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.
Title: Re: Cocoa TStatusBar bug
Post by: VTwin 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.
Title: Re: Cocoa TStatusBar bug
Post by: skalogryz 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
Title: Re: Cocoa TStatusBar bug
Post by: VTwin 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.
Title: Re: Cocoa TStatusBar bug
Post by: skalogryz 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
Title: Re: Cocoa TStatusBar bug
Post by: VTwin on January 01, 2020, 11:21:06 pm
Many thanks. Unfortunately, I just tried trunk and there is no change in the behavior.
Title: Re: Cocoa TStatusBar bug
Post by: skalogryz on January 02, 2020, 12:45:01 am
need a sample
Title: Re: Cocoa TStatusBar bug
Post by: VTwin on January 02, 2020, 05:26:26 am
Thanks, I understand. I will try to provide one.
Title: Re: Cocoa TStatusBar bug
Post by: VTwin 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.
Title: Re: Cocoa TStatusBar bug
Post by: skalogryz on January 03, 2020, 08:40:48 pm
I can't see what's wrong with the sample:
https://www.dropbox.com/s/15gra9v4numoine/Screen%20Recording%202020-01-03%20at%202.37.48%20PM.mov?dl=0
Title: Re: Cocoa TStatusBar bug
Post by: VTwin on January 03, 2020, 08:53:19 pm
Sorry, I uploaded wrong file. See attached.
Title: Re: Cocoa TStatusBar bug
Post by: skalogryz on January 04, 2020, 04:21:52 am
r62481
Title: Re: Cocoa TStatusBar bug
Post by: VTwin on January 04, 2020, 04:51:16 am
I'm getting  a build error on r62482.

Code: Pascal  [Select][+][-]
  1. Assembling (pipe) ../../units/x86_64-darwin/cocoa/cocoawsforms.s
  2. Compiling cocoawsstdctrls.pas
  3. Fatal: Compilation aborted
  4. An unhandled exception occurred at $0000000100058334:
  5. EListError: List index exceeds bounds (30)
  6.   $0000000100058334

I'll try again tomorrow.
Title: Re: Cocoa TStatusBar bug
Post by: VTwin on January 04, 2020, 04:55:11 pm
Excellent! Fixed in trunk.

Thanks so much!
TinyPortal © 2005-2018