Recent

Author Topic: PageControl cannot change TabSheet if Label on Panel on Tabsheet  (Read 646 times)

jipété

  • New Member
  • *
  • Posts: 31
Hello,

discovered that strange behaviour of a PageControl with two TabSheets if a TabSheet holds a Panel which holds a Label : no way to select the other TabSheet with mouse (works fine with arrow keys of keyboard).

If the Label is outside the Panel, everything works as expected.

See attached gif file which shows the problem :
(cannot see animation of attached gif file, dunno why... --> right click on gif file and choose to see it in another tabsheet of brower).

Context : Linux Debian 11.3 / Gtk 2.24, FPC 3.2.2 Laz 2.2.0
Broken config, see below.
Working config, see below.

Thanks,
--
jp
« Last Edit: June 18, 2022, 11:00:29 am by jipété »

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #1 on: June 18, 2022, 11:10:02 am »
No repro here. GTK2, Ubuntu 20 x64, and mouse clicks work ok with 3 TabSheets.
Attach small compileable project.


jipété

  • New Member
  • *
  • Posts: 31
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #2 on: June 18, 2022, 11:20:10 am »
No repro here. GTK2, Ubuntu 20 x64, and mouse clicks work ok with 3 TabSheets.
:o

Attach small compileable project.
Sure. See below :

Thx

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #3 on: June 18, 2022, 11:45:00 am »
Reproduced in your proj. Note: TPageControl lays on TGroupBox! If I move it out on a TForm, all is OK.

wp

  • Hero Member
  • *****
  • Posts: 10045
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #4 on: June 18, 2022, 11:58:33 am »
I can confirm the issue with Linux Mint21  and OpenSUSE Tumbleweed (both 64bit and gtk2), and Linux Mint 19 (32 bit, gtk2; BUT NOT gtk3)

Please post a bug report and attach your demo.

Some observations (please mention them in the bug report):
- So far, I only found the Label to be the only control which causes this.
- I can switch pages by code, i.e. PageControl1.ActivePageIndex := 1 is fine. It seems to be the click which causes the problem.
- When the Labels's AutoSize is false, the bug is gone.
- It is essential that the PageControl is inside a GroupBox; a PageControl directly in the form, or in a Panel, does not show the issue.

As a workaround, you can use a TStaticText.

dseligo

  • Hero Member
  • *****
  • Posts: 708
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #5 on: June 18, 2022, 12:10:11 pm »
I can confirm problem under Debian 11.3.
Under Windows 11 it works normal.

mercurhyo

  • Full Member
  • ***
  • Posts: 219
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #6 on: June 18, 2022, 12:17:14 pm »
hm I remember I had such problem. The way to bypass I found was to replace the whole content of a tabsheet by a TFrame container. If it helps, it's cool  ;D

You design your tabsheets apart inside frames (TFrame), you then drop a frame per tabsheet. I guess pagecontrol then manages 1 component by tabsheet, because frames are self managed
« Last Edit: June 18, 2022, 12:20:48 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

jipété

  • New Member
  • *
  • Posts: 31
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #7 on: June 18, 2022, 12:19:54 pm »
- So far, I only found the Label to be the only control which causes this.
TLabeledEdit create the same problem, BUT components need to be on a TPanel on a TabSheet...

- When the Labels's AutoSize is false, the bug is gone.
Interesting, but no way to do that with TLabeledEdit.

As a workaround, you can use a TStaticText.
Oh, discovered that if I have more components, it works ! Crazy behaviour !
For example,
Code: Pascal  [Select][+][-]
  1. Form
  2.   GroupBox
  3.     PageControl
  4.       TabSheet
  5.         GroupBox
  6.           Panel
  7.             Label (bold by forum)
  8.       TabSheet
works !

I can confirm the issue with Linux Mint21  and OpenSUSE Tumbleweed (both 64bit and gtk2), and Linux Mint 19 (32 bit, gtk2; BUT NOT gtk3)
Please post a bug report.
Dunno how to do that.
« Last Edit: June 18, 2022, 12:23:48 pm by jipété »

mercurhyo

  • Full Member
  • ***
  • Posts: 219
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #8 on: June 18, 2022, 12:24:14 pm »
@jipété
please give it a try

migrate your sheet content inside a TFrame and drop the frame on the TPageControl control. (see my above comment) it solved the issue for me 2 years ago (crossplatfarm way ON)
« Last Edit: June 18, 2022, 12:27:08 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

jipété

  • New Member
  • *
  • Posts: 31
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #9 on: June 18, 2022, 12:47:19 pm »
@jipété
please give it a try

migrate your sheet content inside a TFrame and drop the frame on the TPageControl control. (see my above comment) it solved the issue for me 2 years ago (crossplatfarm way ON)
Not here !
Same crazy behaviour, PageControl does not recognize mouse clicks, even with 3 tabs.

EDIT
Funny thing is the fact that with your frame's idea, even in design time, PageControl does not work anymore !
See png attached
I must play with the frame unit, not the ??? inserted on the Form to be ok.
/EDIT
« Last Edit: June 18, 2022, 01:03:40 pm by jipété »

mercurhyo

  • Full Member
  • ***
  • Posts: 219
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #10 on: June 18, 2022, 01:58:12 pm »
Code: Pascal  [Select][+][-]
  1.  
  2. interface
  3. ...
  4.  
  5. type
  6. THublot = class(TForm)
  7.     MenuItem9: TMenuItem;
  8.     PageControl: TPageControl;
  9.     RstPAction: TAction;
  10.     GoAction: TAction;
  11.     BrakeAction: TAction;
  12.     EndAction: TAction;
  13.     IniProps: TIniPropStorage;
  14.     PopupAction: TAction;
  15.     ActionList: TActionList;
  16.     MainMenu: TMainMenu;
  17.     MenuItem1: TMenuItem;
  18.     MenuItem2: TMenuItem;
  19.     MenuItem3: TMenuItem;
  20.     MenuItem4: TMenuItem;
  21.     MenuItem5: TMenuItem;
  22.     MenuItem6: TMenuItem;
  23.     MenuItem7: TMenuItem;
  24.     MenuItem8: TMenuItem;
  25.     Separator2: TMenuItem;
  26.     Separator3: TMenuItem;
  27.     CfgTabSheet: TTabSheet;
  28.     LogTabSheet: TTabSheet;
  29.     ThinMenu: TPopupMenu;
  30.     Separator1: TMenuItem;
  31.     StatusBar: TStatusBar;
  32.     TrayIcon: TTrayIcon;
  33.     procedure BrakeActionExecute(Sender: TObject); // stop server
  34.     procedure EndActionExecute(Sender: TObject); // Quit
  35.     procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
  36.     procedure GoActionExecute(Sender: TObject); // run server
  37.     procedure PopupActionExecute(Sender: TObject);
  38.     procedure FormCreate(Sender: TObject); // init stuffs
  39.     procedure FormHide(Sender: TObject);
  40.     procedure FormShow(Sender: TObject);
  41.     // hide/show UI while sync toggling trayicon
  42.     procedure FormWindowStateChange(Sender: TObject);
  43.     procedure RstPActionExecute(Sender: TObject); // reset UI
  44.   private
  45.     FCloseCmd: boolean;
  46.     LastWindowState: TWindowState;
  47.     function GetRunning: boolean;
  48.     procedure SetFirstPlacement;
  49.     procedure SetRunning(AValue: boolean);
  50.   protected
  51.     CfgFrame: TCfgFrame;
  52.     LogFrame: TLogFrame;
  53.   public
  54. ...
  55.  
implementation
...

Code: Pascal  [Select][+][-]
  1. procedure THublot.FormCreate(Sender: TObject);
  2. var
  3.   cfgdir: string;
  4. begin
  5.   cfgdir := GetAppConfigDir(False);
  6.   if AnsiLastChar(cfgdir) <> PathDelim then cfgdir := cfgdir + PathDelim;
  7.   TrayIcon.Icon := Application.Icon;
  8.   Caption := Application.Title;
  9.   LastWindowState := WindowState;
  10.   TrayIcon.Hint := Caption;
  11.   IniProps.IniFileName := cfgdir + Caption + '.ini';
  12.   if not FileExists(IniProps.IniFileName) then SetFirstPlacement;
  13.   IniProps.Restore;
  14.   CfgFrame := TCfgFrame.Create(Self);
  15.   CfgFrame.Parent := CfgTabSheet;
  16.   CfgFrame.Align := alClient;
  17.   CfgFrame.PortSpinEdit.Value :=
  18.     StrToIntDef(IniProps.StoredValue['Port'], 16412);
  19.   cfgdir := IniProps.StoredValue['Folder'];
  20.   if (cfgdir = EmptyStr) or not DirectoryExists(cfgdir) then
  21.     IniProps.StoredValue['Folder'] := GetUserDir;
  22.   CfgFrame.DirEdit.Directory := IniProps.StoredValue['Folder'];
  23.   LogFrame := TLogFrame.Create(Self);
  24.   LogFrame.Parent := LogTabSheet;
  25.   LogFrame.Align := alClient;  
  26. ...

I built frames manually in Form.OnCreate. that was no big deal
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

mercurhyo

  • Full Member
  • ***
  • Posts: 219
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #11 on: June 18, 2022, 02:02:26 pm »
dont forget to Create(Self) frames (Mainform is owner) and then set frame.Parent to the PageControl appropriate sheet all this is in my code lol
« Last Edit: June 18, 2022, 02:09:00 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

mercurhyo

  • Full Member
  • ***
  • Posts: 219
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #12 on: June 18, 2022, 02:14:28 pm »
better to dynamically create at runtime maybe, as I did... IDK ... in case of lazarus designer bottlenecks lol
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

jipété

  • New Member
  • *
  • Posts: 31
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #13 on: June 18, 2022, 02:26:31 pm »
dont forget to Create(Self) frames (Mainform is owner)
I don't understand why I must Create a frame which is created in the ide.
and then set frame.Parent to the PageControl appropriate sheet all this is in my code lol
Code: Pascal  [Select][+][-]
  1. frame.Parent  := tabsheet1;
does not do what I'm expecting to see and, imho, I think using frames for this job is like taking the big 4x4 to go to the grocery 200 m far.

mercurhyo

  • Full Member
  • ***
  • Posts: 219
Re: PageControl cannot change TabSheet if Label on Panel on Tabsheet
« Reply #14 on: June 18, 2022, 02:33:58 pm »
I dont pretend to make you follow my way @jipété. I just mention that using DYNAMIC frames works very well for me ... if it can help i'm happy, if not, i dont care lol

about philosophy : that has nothing to do here but yep i own a ferrari and i use it also for small courses hehehe
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

 

TinyPortal © 2005-2018