Forum > LCL

TabSheet in PageControl Enabled/Disabled problem

(1/2) > >>

jipété:
Hello,

1 PageControl with 4 TabSheets.
1 button on TabSheet1 with 1 procedure :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  with TabSheet4 do Enabled := not Enabled;I want to enable/disable the 4th TabSheet but...
pagecontrol_problem.gif

As one can see, TabSheet4 is always enabled when I want it to be disabled, grayed, unavalaible, unreachable, as written in the mini-help in the Objects' Inspector :
pagecontrol-problem.png
"When Enabled is set to False, the control is displayed with a "grayed-out" appearance."

What can I do ?
Thanks for the tips.

Linux Debian 11.8 64bits, GTK2, Lazarus 2.2.6 and FPC 3.2.2

paweld:
As you can see in the animation, the page is grayed out. Setting TabSheet.Enable to False will make all the controls on that page inactive, but you will still be able to switch to that page.
You can use the TabSheet.TabVisible property, then when set to False the page will disappear and you will not be able to switch to it.

jipété:
Hi !


--- Quote from: paweld on November 03, 2023, 01:24:20 pm ---you will still be able to switch to that page.
--- End quote ---
I don't want that behaviour.
I don't want a hidden TabSheet, I want it grayed, as explained in the little help : "When Enabled is set to False, the control is displayed with a "grayed-out" appearance."
Like that, for example, which use 4 times the same code as in my first post, only the name of the object is changed :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  with Button4      do Enabled := not Enabled;  with Edit1        do Enabled := not Enabled;  with CheckBox2    do Enabled := not Enabled;  with RadioButton1 do Enabled := not Enabled;
otherscontrols_ena-dis.gif

TRon:
hi jipété


--- Quote from: jipété on November 03, 2023, 03:10:20 pm ---
--- Quote from: paweld on November 03, 2023, 01:24:20 pm ---you will still be able to switch to that page.
--- End quote ---
I don't want that behaviour.
I don't want a hidden TabSheet, I want it grayed, as explained in the little help : "When Enabled is set to False, the control is displayed with a "grayed-out" appearance."
...

--- End quote ---
Perhaps I am daft but I really do not understand what behavior you are expecting (despite your attached and very nice animated gifs).

Can you disable a tabsheet: yes
When disabled will it then gray out the components on that tabsheet (by default): yes
When disable can you still click the tabsheet and view the contents of/controls on the tabsheet: yes.

That is the default standard behavior for tpagecontrol and its tabsheets and your posts seem to imply that it is exactly the behavior that you expect to happen but at the same time state that it is not the behaviour that you expected. That leaves the reader (or at least me) confused.

Could you elaborate on what it is that you actually expect to happen ?

PS: grasping straws here: do you perhaps want the tabsheet to keep being enabled but all the controls (or a portion of them) on that tabsheet disabled ? That way the tabsheet itself will not be grayed out but the individual controls on that tabsheet will (as long as you select them to be disabled).


Seems I am being thick today, sorry for that. In my defense I know how the control is suppose to work so forgot that you are probably new to the (default) behavior of the control.

Am I correct when I state that you simply want the text in the page control for that disabled tab to look like is is disabled, and as a consequence of that are not able to press the disabled tabsheet so that the user is not able to see and or switch to the tabsheet at all ?

Because if that is the behavior you are looking for then that is not possible with tpagecontrol. In that case you might perhaps be better of by using a custom 3th party control that does support these kind of features out of the box (unfortunately I am not familiar with a 3th party control that offers that functionality or I missed that it could so perhaps someone else might be able to provide you with that information).

For more background information on that specific behavior see also this thread.

jipété:
Due to the fact that many controls turn grey when they are disabled (as in my .gif), I expected the same behaviour : if something in the code doesn't need access to Tab4, that tab is disabled so it's still here but greyed and a click on it has no effect.

For example, Tab4 used for external backup : if no disk is connected, tab is disabled (= visible but greyed, classic ergonomy,  :)) and when a disk is connected, tab becomes enabled, imho it's better than a tab visible or not (=flickering form,  %)), or always visible but components enabled or disabled (stupid to enter a tab and no way to work with).

And if it is not possible, I'm sad  :'( <-- smiley doesn't work

Navigation

[0] Message Index

[#] Next page

Go to full version