Enable/Disable Sections based on prerequisites?
Hello!
I'm just learning NSIS, and so far I am enjoying the ride. It seems pretty straightforward so far, but I've hit a problem that I can't find an answer to with searches in the forums and Google.
Problem Background:
I am writing a plugin for web browsers on Windows. Usually Internet Explorer will be installed, but other browsers like Firefox, Chrome, Safari, and Opera will be installed as well. The plugin has different installation locations based on which browser it's for, so I've set up different Sections for each browser type (all contained within a SectionGroup). I also have the details of installation already completed for each browser type.
Problem:
I'm trying to add functionality to the installer that will enable/disable the proper section(s) if the user has the particular browser installed (basically just trying to make it an 'intelligent' installer). For example, if the user has IE and Firefox installed, those plugin sections will be selected automatically, and ideally the others (Chrome, Safari, and Opera) would all be disabled/grayed out.
I already have the actual tests for each browser completed, so I know if each browser is installed. The problem is that when I try to add this code to the .onInit callback that it's not working. In fact, for some reason it modifies the selection tree by moving the web browser sections to the same level as the SectionGroup.
I've tried adding the testing code to the .onSelChange function too, but that makes things really messy as well.
Here is some of the example code (just Firefox for easier reading). IsFirefoxInstalled is initialized as part of the .onInit callback.
!include Sections.nsh
...
# If the non-IE web browsers are installed, automatically select them.
# If not, disable the selection of that item.
${If} $IsFirefoxInstalled == "1"
!insertmacro SelectSection MozillaFirefox
${Else}
!insertmacro UnselectSection MozillaFirefox
${EndIf}
Is NSIS capable of doing something like this? If so, do I have the right idea, or am I going the wrong direction? Why won't this work?
Any help someone could provide would be greatly appreciated.
Thanks!
-Bill