Old 31st July 2004, 10:28   #1
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
Change radiobutton in .oninit function

Thank for this very good forum, i've learned a lot with it.
Sorry for my bad english, i'm not english native.

so here's my problem:
in my scrip i use radiobutton in a .onselchange function:

section $(SecHP20Name) hp20
WriteRegDWORD ....
WriteRegDWORD ....
sectionend
section /o $(SecHP21Name) hp21
WriteRegDWORD ....
WriteRegDWORD ....
sectionend
section /o $(SecHP51Name) hp51
WriteRegDWORD ....
WriteRegDWORD ....
sectionend

Function .onSelChange
!insertmacro StartRadioButtons $8
!insertmacro RadioButton ${hp20}
!insertmacro RadioButton ${hp21}
!insertmacro RadioButton ${hp51}
!insertmacro EndRadioButtons
FunctionEnd


this works great, but in .oninit function i need to change the default selected radiobutton but if i use sectionsetflags or !insertmacro SelectSection, it select one of the radiobutton without unselect the others one (like if the radiobutton wasn't active).

i hope i've been clear (if not i'll try to be more acurate)

thanks in advance

++
Satsuki is offline   Reply With Quote
Old 31st July 2004, 12:26   #2
mumuri
Junior Member
 
Join Date: Jul 2004
Location: bordeaux -France
Posts: 19
You only have to use sectionsetflags to unset the others button

SectionSetFlags 0 0x10 ; this button is inactive
SectionSetFlags 1 0x10 ; this button is inactive too
SectionSetFlags 2 0x01 ; this button is active

i don't know if you want to disable the button or only unselect it. 0x10 is to disable it. Look in the doc to find the code to unselect them .
mumuri is offline   Reply With Quote
Old 31st July 2004, 12:33   #3
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
simply include the sections header file:
code:
!include Sections.nsh

inside this, u'll find some macros for radio-button behaviour. works really good.
Comm@nder21 is offline   Reply With Quote
Old 31st July 2004, 12:51   #4
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
if i use sectionsetflags to unsheck radiobutton it's buggy, the sction is unshecked but the radiobutton works as if it is checked, for exemple i see:
[0]
[0]
[X]
but when i sheck the first one:
[X]
[0]
[X]
and i want:
[X]
[0]
[0]

what i mean is when i use sectionsetflags, the sections are shecked but the radiobuton consider that the section are as they are before the use of sectionsetflags... so it's no use.

i just want a way to change the default shecked button, that all, but all the way i've found to change it make the radiobutton bug

++
Satsuki is offline   Reply With Quote
Old 31st July 2004, 12:58   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
From Sections.nsh:
Quote:
; You should pass a variable that keeps the selected section
; as the first parameter for this macro. This variable should
; be initialized to the default section's index.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 31st July 2004, 13:00   #6
mumuri
Junior Member
 
Join Date: Jul 2004
Location: bordeaux -France
Posts: 19
have you read this ????
http://forums.winamp.com/showthread....hreadid=188384
he has the same problems as you .
mumuri is offline   Reply With Quote
Old 31st July 2004, 13:34   #7
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
thanks i'm going to read all that ^^

++
Satsuki is offline   Reply With Quote
Old 31st July 2004, 14:03   #8
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
i got exactly the same bug when i change the default with

Push $0
StrCpy $8 ${hp21}
SectionGetFlags ${hp21} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${hp21} $0
SectionGetFlags ${hp20} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${hp20} $0
SectionGetFlags ${hp51} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${hp51} $0
Pop $0

this code unselect the first option and select the second option but when i sheck an other radiobuton i get :
[0]
[X]
[X]
instead of :
[0]
[0]
[X]


++
Satsuki is offline   Reply With Quote
Old 31st July 2004, 14:38   #9
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
If you want to change the default "radiobutton" section in .onInit you'll also need to change the line

section $(SecHP20Name) hp20

to

section /o $(SecHP20Name) hp20

(i.e. ensure none of the sections are selected by default)

otherwise you could end up with two sections selected at the same time.
pengyou is offline   Reply With Quote
Old 31st July 2004, 14:43   #10
mumuri
Junior Member
 
Join Date: Jul 2004
Location: bordeaux -France
Posts: 19
lol, sorry,i was just saying that you should watch the one-section.nsi .

Your problem come from the fact that you have to use a variable to keep the selected option (like kichik said)

All is explain in one section.nsi .

Last edited by mumuri; 31st July 2004 at 16:17.
mumuri is offline   Reply With Quote
Old 31st July 2004, 16:31   #11
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
section /o $(SecHP20Name) hp20
WriteRegDWORD ...
WriteRegDWORD ...
sectionend
section /o $(SecHP21Name) hp21
WriteRegDWORD ...
WriteRegDWORD ...
sectionend
section /o $(SecHP51Name) hp51
WriteRegDWORD ...
WriteRegDWORD ...
sectionend

Function .onInit
ReadRegStr $R9 .....
StrCmp $R9 "..." goto20 goto21c
goto20:
StrCpy $8 ${hp20}
!insertmacro SelectSection ${hp20}
goto21c:
StrCmp $R9 "..." goto21 goto51c
goto21:
StrCpy $8 ${hp21}
!insertmacro SelectSection ${hp21}
goto51c:
StrCmp $R9 "..." goto51 gotofinal
goto51:
StrCpy $8 ${hp51}
!insertmacro SelectSection ${hp51}
gotofinal:
FunctionEnd

Function .onSelChange
!insertmacro StartRadioButtons $8
!insertmacro RadioButton ${hp20}
!insertmacro RadioButton ${hp21}
!insertmacro RadioButton ${hp51}
!insertmacro EndRadioButtons
FunctionEnd

same bug here, i've read a lot the one-section.nsi but if i want to change the default radiobutton in it, it make the same bug to ...
sorry for bother you but i don't understand at all why it doesn't work (if you can explain with a concret exemple instead of some abstract definition (i'm not english native so thecnical english is not easy to understand for me))

thanks again

++
Satsuki is offline   Reply With Quote
Old 31st July 2004, 16:36   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Your code works just fine for me, after replacing all of the triple dots with something meaningful, of course... There must be something else in the script. You should attach your entire script.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 31st July 2004, 17:14   #13
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
my script is ok if hp20 is the radiobutton by default.
if it's not, when you try to select an other radiobutton, it bugg.
i'm going to simplifie my scrip, and post it here after that (more than 1200 lines of code)

++
Satsuki is offline   Reply With Quote
Old 31st July 2004, 17:29   #14
Satsuki
Junior Member
 
Join Date: Jul 2004
Posts: 30
must realy have something bad in my script, i've tested this script and it works perfectly well:

!include "MUI.nsh"
!include "Sections.nsh"

Name "test1"
OutFile "test1.exe"

InstallDir "$PROGRAMFILES\test1"

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "French"


section /o "HP2.0" hp20
WriteRegDWORD HKCU "Software\test" "remind" "20"
sectionend
section /o "HP2.1" hp21
WriteRegDWORD HKCU "Software\test" "remind" "21"
sectionend
section /o "HP5.1" hp51
WriteRegDWORD HKCU "Software\test" "remind" "51"
sectionend


Function .onInit

ReadRegStr $R9 HKCU "Software\test" "remind"
StrCmp $R9 "20" goto20 goto21c
goto20:
StrCpy $8 ${hp20}
!insertmacro SelectSection ${hp20}
goto21c:
StrCmp $R9 "21" goto21 goto51c
goto21:
StrCpy $8 ${hp21}
!insertmacro SelectSection ${hp21}
goto51c:
StrCmp $R9 "51" goto51 gotofinal
goto51:
StrCpy $8 ${hp51}
!insertmacro SelectSection ${hp51}
goto endsel
gotofinal:
StrCpy $8 ${hp20}
!insertmacro SelectSection ${hp20}
endsel:

functionend


Function .onSelChange
!insertmacro StartRadioButtons $8
!insertmacro RadioButton ${hp20}
!insertmacro RadioButton ${hp21}
!insertmacro RadioButton ${hp51}
!insertmacro EndRadioButtons
FunctionEnd



!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_FUNCTION_DESCRIPTION_END


thanks for all, i'm going to verif my script ^^

++

[EDIT] bug spotted, i had a bad command in my .oninit function (400 lines of code that looks like a mess so that my fault).
thank for all, i learned a lot about radiobutton.
Satsuki 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