Disable individual tabsheets of pagecontrol lazarus / 31-LCL ---------------------------------------------------------------------- Pascal · 2016-07-18 08:05 Hello, does anybody know how to disable individual tabsheets of a pagecontrol? TTabSheet.Enable does not seem to work. Regards Pascal ---------------------------------------------------------------------- rvk · 2016-07-18 09:12 Are you sure? For me, when I do TTabSheet.Enable := false all the components on that sheet are disabled. ---------------------------------------------------------------------- howardpc · 2016-07-18 09:14 What platform/target are you working on? On Linux, TTabsheet.Enabled works fine here for gtk2 and qt. ---------------------------------------------------------------------- eric · 2016-07-18 11:57 Do you actually want to disable the tab but leave it visible, or make it not visible? If you want the latter, then TTabSheet.TabVisible is the property to use. ---------------------------------------------------------------------- Graeme · 2016-07-18 13:00 Quote from: eric on July 18, 2016, 01:57:04 pm... or make it not visible? If you want the latter, then TTabSheet.TabVisible is the property to use. Interesting... why the non-standard property name?  Why not TTabSheet.Visible like you get for TLabel, TButton etc. ---------------------------------------------------------------------- wp · 2016-07-18 13:06 The usual answer: Because Delphi calls it this way... ---------------------------------------------------------------------- Blaazen · 2016-07-18 13:43 QuoteInteresting... why the non-standard property name?  Why not TTabSheet.Visible like you get for TLabel, TButton etc. No, it is not the same. TabVisible hides only the tab, not the TabSheet itself. The TabSheet is still there but is unreachable by keybord or mouse. Yet it can be shown by code. The name is chosen well. ---------------------------------------------------------------------- wp · 2016-07-18 13:56 If I call "Panel.Visible= false" then the panel "is still there but is unreachable by keyboard an mouse. Yet it can be shown by code". - Your words... So what would be the difference between Tabsheet.Visible and Tabsheet.TabVisible? ---------------------------------------------------------------------- rvk · 2016-07-18 14:08 Quote from: wp on July 18, 2016, 03:56:54 pmIf I call "Panel.Visible= false" then the panel "is still there but is unreachable by keyboard an mouse. Yet it can be shown by code". - Your words... So what would be the difference between Tabsheet.Visible and Tabsheet.TabVisible? If it was used like you claim it wasn't possible to switch to the tab without showing the tab in the TPageControl. Visible would in that case add the tab back in the tabs in TPageControl. The way it is now you can still have the TabVisible on false (no tab) but the TTabSheet still visible (with TPageControl.ActivePage := TTabSheet; TTabsheet.Visible isn't implemented at all for obvious reasons. (The sheet should always be there even if there is no tab for it. And it there is a tab for it it the sheet also should always be visible.) ---------------------------------------------------------------------- Blaazen · 2016-07-18 14:11 That's something else. When TabSheet3.TabVisible=False, you can do PageControl.ActivePage:=TabSheet3. The TabSheet3 and its content will be displayed, however its tab*) is not shown. Panel remains invisible until you do Panel.Visible:=True. *) We sometimes use word "Tab" for the whole page (tabsheet) but it is wrong. The "tab" is only the small part above (bottom, left or right) with caption. ---------------------------------------------------------------------- howardpc · 2016-07-18 14:41 Quote from: Blaazen on July 18, 2016, 04:11:15 pmWhen TabSheet3.TabVisible=False, you can do PageControl.ActivePage:=TabSheet3. The TabSheet3 and its content will be displayed, however its tab*) is not shown. Panel remains invisible until you do Panel.Visible:=True. This may be widget-specific behaviour. With gtk2 I find that with TabVisible False you can set PageControl.ActivePage to that tab without an error. However the page is not shown whatever the value of the tabsheet's Visible property. The only way to access it is by setting TabVisible to True which not only shows the tab, but makes the whole tabsheet visble and brings it to the front. ---------------------------------------------------------------------- Graeme · 2016-07-18 22:42 Quote from: Blaazen on July 18, 2016, 04:11:15 pmThat's something else. When TabSheet3.TabVisible=False, you can do PageControl.ActivePage:=TabSheet3. The TabSheet3 and its content will be displayed, however its tab*) is not shown. Panel remains invisible until you do Panel.Visible:=True. Thanks for the explanation. Does anybody have an actual use-case for that behaviour? I can't think of any now, but then it is midnight here. ;-) ---------------------------------------------------------------------- rvk · 2016-07-18 22:48 Quote from: Graeme on July 19, 2016, 12:42:34 amDoes anybody have an actual use-case for that behaviour? I can't think of any now, but then it is midnight here. ;-) For implementing an Easter egg  (A cool hidden sheet with lots of goodies) (Past midnight here too  ) ---------------------------------------------------------------------- Graeme · 2016-07-18 22:50 Quote from: howardpc on July 18, 2016, 04:41:02 pmThis may be widget- specific behaviour. I can confirm that - the joys of LCL.  I tested with FreeBSD and used LCL-GTK2. I created three pages in a PageControl. At runtime I set TabSheet2.TabVisible = False.  I then use a button's OnClick to set PageControl1.ActiveTab := TabSheet2; which actually switched to the 3rd tab. So no, it doesn't work as expected. :-/ To make matters worse, the "Restricted" tab in the Object Inspector doesn't mention TabVisible - which it should based on my testing. ---------------------------------------------------------------------- Graeme · 2016-07-18 23:01 Just had a quick look an Mantis. This TabVisible issue has been reported back in 2013 already against the Carbon widgetset. I added a comment that it doesn't work under LCL-GTK2 either.   http://mantis.freepascal.org/view.php?id=21723 ---------------------------------------------------------------------- Pascal · 2016-07-19 06:54 Quote from: eric on July 18, 2016, 01:57:04 pmDo you actually want to disable the tab but leave it visible, or make it not visible? If you want the latter, then TTabSheet.TabVisible is the property to use. I just want to have the tab visible but not accessable (grayed out) by user. I want to implement a kind of wizzard where i can only reach the next step if all needed information have been entered. ---------------------------------------------------------------------- rvk · 2016-07-19 07:04 Quote from: Pascal on July 19, 2016, 08:54:12 amI just want to have the tab visible but not accessable (grayed out) by user. I want to implement a kind of wizzard where i can only reach the next step if all needed information have been entered. You can disable the Tabsheet (Enabled := false) and everything on that tab is grayed out. You can't disable the tab itself. You'll need to do some coding to draw the tab as disabled (grayed out) and in the TPageControl events ((OnChanging I think) you need to skip that page. ---------------------------------------------------------------------- wp · 2016-07-19 08:11 OnChanging was my first though when reading this, but it has the disadvantage that it does not tell which sheet is going to be selected. It is good for validation of the current sheet only, but not for disabling entering another sheet. I think the only way to achieve this at the moment is to use the OnChange event, check if the forbidden page is entered and in this case return to the previous one. Of course the forbidden page will flash up for a moment. Not nice. How about adding a OnChangingEx event: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.PageControl1ChangingEx(Sender: TObject; NewPage: TTabSheet; var AllowChange: Boolean); ---------------------------------------------------------------------- wp · 2016-07-19 08:16 Quote from: Graeme on July 19, 2016, 12:42:34 amQuote from: Blaazen on July 18, 2016, 04:11:15 pmThat's something else. When TabSheet3.TabVisible=False, you can do PageControl.ActivePage:=TabSheet3. The TabSheet3 and its content will be displayed, however its tab*) is not shown. Panel remains invisible until you do Panel.Visible:=True. Thanks for the explanation. Does anybody have an actual use-case for that behaviour? I can't think of any now, but then it is midnight here. ;-) "Wizard" forms which display many different items dependent on a selector such as a treeview. The items are grouped on a pagecontrol, tabs are hidden at designtime. Depending on the selection in the treeview a different tabsheet is displayed. Another way would be to use a TNotebook but it is much less convenient in the design phase because the pagecontrols are still visible at designtime even if TabVisible = false. ---------------------------------------------------------------------- Pascal · 2016-07-19 09:10 What about a new property for TPageControl / TCustomTabControl? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i property PageEnabled[Index: Integer]: Boolean; ---------------------------------------------------------------------- Blaazen · 2016-07-19 10:02 QuoteWhat about a new property for TPageControl / TCustomTabControl? PageControls are native components so this would require support in all (WIn, Qt, GTk2, Carbon and Cocoa) widgetsets. I doubt they have it. As you can see from Graeme's posts above, there are already problems with TabVisible (in Carbon and GTk2). PageEnabled (you probably meant TabEnabled) would be even worse.