Recent

Author Topic: Problem in drawing controls on TTabSheet  (Read 6026 times)

VTwin

  • Hero Member
  • *****
  • Posts: 787
  • Former Turbo Pascal 3 user
Problem in drawing controls on TTabSheet
« on: July 02, 2018, 05:55:24 pm »
I have been trying to build my applications using the Cocoa widget set to look for issues. I am pretty impressed with the results, but there are still some issues.

I have a complex preferences dialog that uses a TPageControl with about 20 TTabSheets, each of which has 10 to 20 or so controls. The Tabs are hidden on the PageControl, and the user selects a page from a TListBox next to it. The current TTabSheet is set using:

Code: Pascal  [Select]
  1. PageControl1.PageIndex := fCurPage;


This works fine in Windows, Linux, and Carbon. In Cocoa however, the controls are all drawn correctly on initial tabsheet, but subsequent tabsheets only display TLabels and TPaintBoxes. All other controls (TCheckBoxs, TComboBoxes, TEdits) are not drawn. If I display the tabs, and click on them (avoiding the above code) the controls are drawn correctly.

I was unsuccessful in duplicating the issue in a small program, so I took the code and removed everything except the minimum. The problem persisted. However, when I moved the form to a new project, and opened it there, the problem went away. I also tried code like:

Code: Pascal  [Select]
  1. PageControl1.PageIndex := fCurPage;
  2. PageControl1.Controls[fCurPage].Update

and:

Code: Pascal  [Select]
  1. PageControl1.PageIndex := fCurPage;
  2. if PageControl1.Controls[fCurPage] is TTabSheet then begin
  3.   ts := TTabSheet(PageControl1.Controls[fCurPage]);
  4.   c := ts.ControlCount;
  5.   for i := 0 to c-1 do
  6.     ts.Controls[i].Update;
  7. end;

Any suggestions or similar issues?
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Problem in drawing controls on TTabSheet
« Reply #1 on: July 02, 2018, 06:00:42 pm »
Any suggestions or similar issues?

I believe the issue with missing controls on TTabSheet has been fixed in trunk.

VTwin

  • Hero Member
  • *****
  • Posts: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #2 on: July 02, 2018, 06:49:24 pm »
Any suggestions or similar issues?

I believe the issue with missing controls on TTabSheet has been fixed in trunk.

Thanks Phil!
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Problem in drawing controls on TTabSheet
« Reply #3 on: July 02, 2018, 06:51:44 pm »
Any suggestions or similar issues?

I believe the issue with missing controls on TTabSheet has been fixed in trunk.

Thanks Phil!

However, I note that clicking above and below the "thumb" on scrollbars does not appear to work, which is odd considering how fundamental that is, particularly on Mac. Have you noticed that? You can see it in the Laz IDE compiled against trunk Cocoa, both in the code editor and anywhere that a TStringGrid is used, for example the version info list.

VTwin

  • Hero Member
  • *****
  • Posts: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #4 on: July 02, 2018, 08:06:42 pm »
However, I note that clicking above and below the "thumb" on scrollbars does not appear to work, which is odd considering how fundamental that is, particularly on Mac. Have you noticed that? You can see it in the Laz IDE compiled against trunk Cocoa, both in the code editor and anywhere that a TStringGrid is used, for example the version info list.

I normally use TDrawGrids, and do not currently have trunk Cocoa installed. [I just tried a simple TStringGrid example, and it seemed to work as expected.]

EDIT: No I am incorrect, the attached simple project does NOT work properly in Cocoa.

EDIT: Bug report filed.
« Last Edit: July 03, 2018, 09:08:55 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #5 on: July 02, 2018, 08:08:14 pm »
Two other issues I noticed:

TDrawGrid - has no scrollbars
TListBox - loses focus when up/down arrow keys are pressed

EDIT: Bug report filed for TListBox
« Last Edit: July 02, 2018, 08:28:53 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #6 on: July 02, 2018, 08:14:47 pm »
TDrawGrid - has no scrollbars

Actually, I tried a simple example, and it shows scrollbars. In my larger applications the DrawGrid does not show scrollbars in Cocoa, but does in Windows, Linux, and Carbon.

@Phil, I wonder if this is related to your observation?

EDIT: Also the DrawGrid does not scroll using the "wheel" in my larger application, again this works in Windows, Linux, and Carbon (and in a simple example). Something is different in the implementation on Cocoa.
« Last Edit: July 02, 2018, 09:53:36 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #7 on: July 02, 2018, 10:34:36 pm »
Here is a DrawGrid example that shows the missing scrollbars (that is, does not show them).

EDIT: Bug report filed.
« Last Edit: July 03, 2018, 07:48:36 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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

MISV

  • Hero Member
  • *****
  • Posts: 633
Re: Problem in drawing controls on TTabSheet
« Reply #8 on: July 03, 2018, 12:18:35 am »
Sounds similar to issue I have reported

Forum threads
http://forum.lazarus.freepascal.org/index.php/topic,41624.0.html

Bug report
https://bugs.freepascal.org/view.php?id=33896
Where culprit is that setting one tabsheet.TabVisible := False will render all following tabsheets content invisible.

However - problem does not seem to be fixed for me
« Last Edit: July 03, 2018, 12:22:57 am by MISV »

VTwin

  • Hero Member
  • *****
  • Posts: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #9 on: July 03, 2018, 12:32:13 am »
Sounds similar to issue I have reported

Forum threads
http://forum.lazarus.freepascal.org/index.php/topic,41624.0.html

Bug report
https://bugs.freepascal.org/view.php?id=33896
Where culprit is that TabVisible := False will render all following tab content invisible.

However - problem does not seem to be fixed for me

Thanks, I saw your report. I was not setting TabVisible, but seemed to get similar results. One or two pages show controls, and the remaining pages show only TLabel and TPaintBox controls. I am having trouble reproducing it in a simple application.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #10 on: July 03, 2018, 01:04:24 am »
I managed to write a small application that reproduces this behavior. I'll post a bug report, but would appreciate any feedback or confirmation before doing so. 

The TButton resizing is another bug, but perhaps that has been reported already.

EDIT: If the ActivePage is set to a page other than the first, two pages are correct (the first and the active page). If the ActivePage page is set to the first, only the first is rendered correctly.

EDIT: Bug report filed
« Last Edit: July 03, 2018, 07:17:47 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #11 on: July 04, 2018, 02:02:09 am »
A bit off topic, but I submitted another bug report for TStatusBar which does not display text.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #12 on: July 14, 2018, 02:08:47 am »
I'd like to thank the Cocoa development team for their hard work. The implementation in 1.9 trunk seems to be in very good shape. 

Clicking above and below the thumb pad in a scrollbar on DrawGrid still does not work, but the other bugs I reported seem to be fixed.

I am feeling optimistic about being able to deliver Cocoa applications before Apple shuts the window.

Thanks!

Cheers,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Problem in drawing controls on TTabSheet
« Reply #13 on: July 14, 2018, 02:18:27 am »
Clicking above and below the thumb pad in a scrollbar on DrawGrid still does not work, but the other bugs I reported seem to be fixed.

The various grid components in the grids unit have always been kind of dodgy on Mac since they're custom control and do not simply wrap a Carbon or Cocoa control. TStringGrid in particular has had many problems over the years so this shouldn't be surprising. It might actually need to be fixed in the LCL, not in the Cocoa widgetset.

Another TStringGrid problem is how text in a cell jumps around when it gains and loses focus. None of the other widgetsets have this problem, only the Cocoa widgetset.

Hope springs eternal, I guess.

VTwin

  • Hero Member
  • *****
  • Posts: 787
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #14 on: July 14, 2018, 03:03:46 am »
Hope springs eternal, I guess.

:) I don't really have other viable options. I've played with multi-platform options. I don't see myself trying to migrate to Python, Java, Xojo (yuck), C++ with wxWidgets or Qt, or ?

My software is free, so if my Mac users have to deal with a few glitches, so be it.

Cheers,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (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