Recent

Author Topic: Fixing or working around issues with TPageControl and TTabControl in gtk2  (Read 371 times)

Nel_Fie

  • Jr. Member
  • **
  • Posts: 57
TPageControl and TTabControl currently have some grave bugs in their implementation for gtk2, in ways that make them basically unusable for my current projects. Could anyone here help me work around them or fixing them?

TPageControl has a bug where contents nested in the tabs end up overlapping with the tab buttons, making them un-clickable, thus preventing any tab change. I've documented this the best I could on GitLab here and here.

TTabControl has its own issues where any setting that adjusts its size to its containing parent (e.g. by setting Align to anything but alNone, through Anchors, or by adjusting its size manually through the OnChangeBounds event of the parent) leads to a ChangeBounds loop, thus crashing the project - sometimes even in the editor. I've also documented this on GitLab here - only with a TScrollBox at the time, but I've run into the same issues with a TGroupBox and a TPanel since.
As far as I could tell from a bit of investigating, this might be caused by some implementation of GetLogicalClientRect which returns a bigger rect than the actual size of the client, thus forcing the parent to expand in response, which then leads the children to adjust again.

Either way, while I'm still searching for possible solutions, I'm running out of ideas fast and coming close to just manually building an alternative to the built-in tab systems altogether, e.g. by using a TComboBox, or creating a row of TButtons to select pages from a notebook instead.

Any ideas how I could avoid having to do that?

wp

  • Hero Member
  • *****
  • Posts: 12784
TPageControl and TTabControl currently have some grave bugs in their implementation for gtk2, in ways that make them basically unusable for my current projects. Could anyone here help me work around them or fixing them?
It seems to me that this has been fixed in Laz/main because I cannot reproduce the issue (Manjaro). Did you check the Laz4.0 RC?

TTabControl has its own issues where any setting that adjusts its size to its containing parent (e.g. by setting Align to anything but alNone, through Anchors, or by adjusting its size manually through the OnChangeBounds event of the parent) leads to a ChangeBounds loop, thus crashing the project - sometimes even in the editor. I've also documented this on GitLab here - only with a TScrollBox at the time, but I've run into the same issues with a TGroupBox and a TPanel since.
As far as I could tell from a bit of investigating, this might be caused by some implementation of GetLogicalClientRect which returns a bigger rect than the actual size of the client, thus forcing the parent to expand in response, which then leads the children to adjust again.
This one can be confirmed.

Nel_Fie

  • Jr. Member
  • **
  • Posts: 57
It seems to me that this has been fixed in Laz/main because I cannot reproduce the issue (Manjaro). Did you check the Laz4.0 RC?

Yes, all issues as described still occur for me with 4.0RC3. Here's the full info from the "About Lazarus" window:

Lazarus 4.0RC3 (rev lazarus_4_0RC3-50-g7f2d12f0f3) FPC 3.2.2 x86_64-linux-gtk2

The TPageControl issue is erratic, I haven't managed to reproduce it 100% myself. I can try to snip out the instance occurring in one of my projects, but I can't guarantee that it'll work.

EDIT: I've dug through some files and found a sample project where the bug occurs. Find it attached below. When running the project, the tabs should be unclickable. By pressing the button on the bottom left, the TPageControl is parented to Form1, where the tabs become clickable. By pressing the button again, the TPageControl is reparented to the TGroupBox, as before, but the tabs should remain clickable.
« Last Edit: April 27, 2025, 06:35:34 pm by Nel_Fie »

 

TinyPortal © 2005-2018