Skip to content
⌘ NSIS Forum Archive

Radiobuttons OnSelChange SectionGroup error

3 posts

Andrew Wallo#

Radiobuttons OnSelChange SectionGroup error

Greetings. Very strange behavior. Context is the components screen, and I'm trapping the onClick event with OnSelChange. That routine uses the following code to stick into $1 the value of the radiobox that was clicked. based on that value, I do stuff controlled in a case statement. I put a message box at the end of this code to show the output of the click and this string of macros.

MOST of these radio buttons are not displayed. ( set to "" ) but because of the way that onSelchange reports the return value from a declared section, the number increases reguardless of if the section is displayed or not... so that if sections 0-9 are hidden, and the first checkbox on the components screen is displayed it will return 10 as the value that was clicked. Ok.. fine...

but now, I've added a sectiongroup and its all gone to crap. If I click on the sectiongroup line or checkbox, it returns 19 (The ordinal id for the last checkbox - section: MDI_sa) and then if I click it again, it returns 18 ( the ordinal of the section labled: MDI_mm ) And then it repeats. 19, 18 ,19 ,18 It never returns 15 ( the ordinal value that would be assigned for the sectiongroup marker if it treated them the same...but if they don't treat them the same, then there is no ordinal 19 and it doesn't make sense again...)


StrCpy $1 $BaseRadioDefault
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1} ; ordinal 0
; most of these are hidden at any one time....
!insertmacro RadioButton ${g1o2} ; ordinal 1
!insertmacro RadioButton ${g1o3} ; ord 2
!insertmacro RadioButton ${g1o4} ; ord 3
!insertmacro RadioButton ${g1o5} ; ord 4
!insertmacro RadioButton ${g1o6} ; ord 5
!insertmacro RadioButton ${g1o7} ; ord 6
!insertmacro RadioButton ${g1o8} ; ord 7
!insertmacro RadioButton ${g1o9} ; ord 8
!insertmacro RadioButton ${g1oA} ; ord 9
!insertmacro RadioButton ${g1oB} ; ord 10
!insertmacro RadioButton ${g1oC} ; ord 11
!insertmacro RadioButton ${g1oA2} ; ord 12
!insertmacro RadioButton ${g1o6B} ; ord 13
!insertmacro RadioButton ${g1o7B} ; ord 14
!insertmacro RadioButton ${MDI}
; This is the group section header. SHOULD Be ordinal 15
!insertmacro RadioButton ${MDI_mx} ; ord 16
; none of these are hidden
!insertmacro RadioButton ${MDI_dc} ; ord 17
; they will always display
!insertmacro RadioButton ${MDI_mm} ; ord 18
!insertmacro RadioButton ${MDI_sa} ; ord 19??
!insertmacro EndRadioButtons

MessageBox MB_OK "Clicked On: $1" ; results in alternating
; values of 19 and 18 when you click on the group header.



I attached the pic of the way the screen displays with two normal options visible and the bottom group showing.

Please, any guidance as to what I'm assuming incorrectly?


Thanks
_Andy
Andrew Wallo#
I'm not sure, but it seems as if it automatically sets $1 to be the last in the list, if there was nothing selected.... and if you click on the SectionGroup 'radiobox' it acts as if theres nothing selected.... and somehow it sets it to the last one...

Then.... if a click is registered and then it doesn't find which section is claiming the Selected Flag ( because the SectionGroup doesn't claim it....???? ) it defaults to the last unselected one....??? That doesn't make a lot of sense.... but its as if the click on the SectionGroup header doesn't count as a click..... and the macro isn't designed to handle this....?...?...?
Andrew Wallo#
Must check the master flag settings for the Setction Group prior to moving next buton

Greetings everyone,

I have a clear answer now to the issue that became rather cluttered on this post:

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.


But a less cluttered framing of the question would be:

What is the effect that a SectionGroup has on the Radiobutton macros..... used in this fashion:

!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${1notINgroup}
!insertmacro RadioButton ${2notINgroup}
!insertmacro RadioButton ${3InGroup}
!insertmacro RadioButton ${4InGroup}
!insertmacro RadioButton ${5InGroup}
!insertmacro EndRadioButtons

The simple state is that if the user clicks on the section group header in teh components page.... then ALL of the untis inside it will be marked as ON... and hence 3 will be on, but 4 will trump it, and 5 will trump 4.

The only way to fix this, is to do soemthing like this:

; presuming that 3InGroup,4InGroup,5InGroup is wrapped with
; a section group marker titled InGroup


!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${1notINgroup}
!insertmacro RadioButton ${2notINgroup}


; get flags for group section
SectionGetFlags ${InGroup} $TempRadioButtonFlagsVar
; test against 35 which is the setting for if a user
; clicked directly onto the section group header....
; the flags for the group header would be 98 if they had
; clicked on a sub option under the group...
; See the flags in the help index under SectionGetFlags

StrCmp $TempRadioButtonFlagsVar "35" 0 NextRadioButton
; if we drop in then we clear the group....
IntOp $TempRadioButtonFlagsVar $TempRadioButtonFlagsVar & ${SECTION_OFF}
SectionSetFlags ${InGroup} $TempRadioButtonFlagsVar
NextRadioButton:

!insertmacro RadioButton ${3InGroup}
!insertmacro RadioButton ${4InGroup}
!insertmacro RadioButton ${5InGroup}
!insertmacro EndRadioButtons