Old 6th July 2016, 22:06   #1
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Section selection flags

Hi all,

My installer has a few features say A, B, C and D and I have used the components page via Section /o in my .nsi script.
All sections are unselected by default.

If A is selected B and C have to be disabled. If A is unchecked they have to be enabled again.
I have been trying a lot of things , I could disable the selections B and C when A is selected through this:
Function .onSelChange

${If} ${SectionIsSelected} ${ServerSec}
SectionSetFlags ${DCM32Sec} 16
SectionSetFlags ${DCM64Sec} 16
${EndIf}

FunctionEnd

But am not able to go back to my original position when A is unselected.
Any suggestions will help!!

--Pavan
pkonduru is offline   Reply With Quote
Old 6th July 2016, 22:31   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,189
Add a ${Else} block to your if. You should not call SectionSetFlags directly, use the macros in sections.nsh!

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th July 2016, 22:52   #3
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
This is what I tried after reading the sections.nsh:

${If} ${SectionIsSelected} ${ServerSec}
SectionSetFlags ${DCM32Sec} ${SF_RO}
SectionSetFlags ${DCM64Sec} ${SF_RO}
${else}
SectionSetFlags ${DCM64Sec} ${SF_SELECTED}
!insertmacro UnselectSection ${DCM64Sec}
SectionSetFlags ${DCM32Sec} ${SF_SELECTED}
!insertmacro UnselectSection ${DCM32Sec}
${EndIf}

--The 2 sections are disabled when I select $ServerSec
--When I unselect both sections are enabled but I am not able to select them on the components page, seem like they are disabled .
pkonduru is offline   Reply With Quote
Old 6th July 2016, 23:02   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,189
Didn't I tell you not to call SectionSetFlags directly? Use the Set/ClearSectionFlag macros.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th July 2016, 23:20   #5
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Am confused , is this how you mean?

!insertmacro ClearSectionFlag ${DCM32Sec} 1
pkonduru is offline   Reply With Quote
Old 6th July 2016, 23:24   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,189
No, use UnselectSection to unselect and ClearSectionFlag to remove ${SF_RO}.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th July 2016, 00:20   #7
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
So this is what I did:

${If} ${SectionIsSelected} ${ServerSec}
!insertmacro UnselectSection ${DCM32Sec}
!insertmacro UnselectSection ${DCM64Sec}

${EndIf}

Selecting Serv will not let me choose either of the other 2 sections which is what I want.

The clearSectionsFlag is defined in Sections.nsh as:

!macro ClearSectionFlag SECTION BITS

I am not sure how to use this macro?
pkonduru is offline   Reply With Quote
Old 7th July 2016, 01:04   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,189
To make a section not read-only: !insertmacro ClearSectionFlag ${DCM32Sec} ${SF_RO}

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th July 2016, 01:19   #9
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Thanks Anders! This Solved my problem, so can help others:

Function .onSelChange

${If} ${SectionIsSelected} ${ServerSec}
!insertmacro UnselectSection ${DCM32Sec}
!insertmacro UnselectSection ${DCM64Sec}
!insertmacro SetSectionFlag ${DCM32Sec} ${SF_RO}
!insertmacro SetSectionFlag ${DCM64Sec} ${SF_RO}

${else}
!insertmacro ClearSectionFlag ${DCM32Sec} ${SF_RO}
!insertmacro ClearSectionFlag ${DCM64Sec} ${SF_RO}

${EndIf}


FunctionEnd
pkonduru is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump