Archive: Persist field values on click of back button.


Persist field values on click of back button.
Hello,

Persist field values on click of back button:

Right now when I enters the values in the textboxes(fields) and clicks on the next button. Now when I click on the back button again that time the values I had entered on the previous page becomes blank. I mean to say the NSIS is not persisting the values for previous pages.

Can anyone please tell me how can I do it?


store the value in a variable, then restore the value into the control when the page is loaded.

For more details... are you using InstallOptions(2/Ex) or nsDialogs?


I am using InstallOptions.


BTW, Do you have code for the above explanation? If yes can you please share it with me.


Thanks for the reply.


okay, for InstallOptions it's pretty simple as it stores the values in the .INI file. So all you have to do is make sure you don't extract the .INI again when the page loads.

There's two easy ways you can do this..

A. Extract any custom dialog INIs in e.g. the onGUIinit callback. This will also extract INIs that you may not end up using and will slow down installer launch a slight bit.


outfile 'customtest.exe'

!include 'LogicLib.nsh'
!include 'MUI.nsh'

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!define MUI_CUSTOMFUNCTION_GUIINIT onGuiInit

var hwnd

Page Custom CustomPre CustomPost
Page Directory

!insertmacro MUI_LANGUAGE "English"


Function onGuiInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "textfield.ini"
FunctionEnd

Function CustomPre
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "textfield.ini"
Pop $hwnd
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd

Function CustomPost
FunctionEnd

Section
SectionEnd


B. Extract the custom dialog INIs when needed, only once. This will only extract the INIs you actually use (if you skip a custom page, its ini won't be extracted), but will make the page showing up be delayed by a fraction.

outfile 'customtest.exe'

!include 'LogicLib.nsh'
!include 'MUI.nsh'

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

var hwnd

Page Custom CustomPre CustomPost
Page Directory

!insertmacro MUI_LANGUAGE "English"

Function CustomPre
${Unless} ${FileExists} "$PLUGINSDIR\unwelcome.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "textfield.ini"
${EndUnless}
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "textfield.ini"
Pop $hwnd
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd

Function CustomPost
FunctionEnd

Section
SectionEnd


I hope that helps - textfield.ini is just an installoptions ini file with a single text field, for testing.