- NSIS Discussion
- disabling component checkbox based on variable
Archive: disabling component checkbox based on variable
jatinkulkarni
27th September 2007 17:35 UTC
disabling component checkbox based on variable
I want to disable a component checkbox based on value contained in one of the variables. Here is the code I tried to use.
Section /o "Server"
${If} $UserRegValue != '1111 2222 3333 4444'
SectionIn RO
${EndIf}
SectionEnd
The problem is that the checkbox is disabled even if $UserRegValue contains string '1111 2222 3333 4444'. How do I achieve conditional disabling of checkbox ?
regards,
Jatin.
kichik
27th September 2007 18:31 UTC
SectionIn is compile time only. To disable it on runtime, add the SF_RO flag using the macros in Sections.nsh.
Section /o Server Server_SEC
SectionEnd
Function .onInit
${If} $UserRegValue != '....'
!insertmacro SetSectionFlag ${Server_SEC} ${SF_RO}
${EndIf}
FunctionEnd
jatinkulkarni
27th September 2007 19:20 UTC
thanks a lot
tmxk
15th May 2008 20:27 UTC
Hi Kichik,
I tried your idea, but it didn't work since function .OnInit is run at the begining of the script when value $UserRegValue is not set yet. Or I did some wrong?
Can you give me more details?
Thanks,
Jue
kichik
15th May 2008 20:36 UTC
$UserRegValue is a specific variable for jatinkulkarni's script. You should replace that with whatever test you have in your script.
tmxk
15th May 2008 20:49 UTC
Actually I use variable R9 instead, but it is not set at the begining.
Thanks.
tmxk
15th May 2008 21:11 UTC
More ideas?
kichik
15th May 2008 21:34 UTC
If you don't set it, it won't be set.
tmxk
15th May 2008 21:54 UTC
But it is set afterwards.
I would like to set the variable afterwards and then base on the value of the variable to disable a section in component page
Thanks for your answer.
tmxk
15th May 2008 22:14 UTC
Hi,
My problem is, the value of the variable will be set according to the selection by user, but function .onInit runs before this, so the value of the variable is not set at that time.
Thanks for your reply.
kichik
15th May 2008 22:29 UTC
Then don't set the component selection in .onInit. Set it as soon as you can set $R9. As long as it's before the components page is displayed, it should be good enough.
tmxk
15th May 2008 22:59 UTC
The value I can set when I leave the custom page.
All the sections will show up in component page. Am I wrong? So where can I check the value of the variable and then set the section to be disabled?
Thanks in advance.