Archive: Back Button not working properly


Back Button not working properly
  Hi All,
From a NSIS script file, I'm trying to do something like this

If the user forgets to enter input, display a messagebox that forces him to enter input.

This works fine but when I hit the back button, it displays the message box instead of navigating to the previous page.

Is there any way to read the value of Back, Next etc from the code? Do they live in register variables? I checked $R1, it's empty!

Would really appreciate any help,
Thanks in advance,
M.J.S

P.S. I'm using NSIS 2.0 and the modern UI.


After you have called the DLL, InstallOptions adds one string to the stack, with one of the following values. [Except for the function "InitDialog" which returns the page handle.]:

success - The user has pressed the Next button
back - The user has pressed the Back button
cancel - The user has pressed the Cancel button
error - An error has occurred, the dialog cannot be displayed.
An example:


InstallOptions::ShowPage "Test.ini"

>Pop $0
>
The return value is returned to variable $0.

Using the leave function is easier.


I tried the leave function approach before I posted to the forum.

page custom Foo "" leaveFoo

Function leaveFoo
;do something
FunctionEnd

When I compiled the script, it zeroed this code out...

Any idea why?


Thanks,
M.J.S


Page custom Foo leaveFoo


Cool, thanks for the help. This works for me. I'm still a little unclear on how I would find the variable in which "back" is stored.

Thanks,
Malathi


Just wonderinf if anyone has answers to the question that I posted...

Thanks.


You mean the text of the button? See the language file for the language string name.


Thanks for your response. I'm actually trying to get this to work for me...

Function customPage

; Do something to get R1. Not sure what exactly...
StrCmp $R1 "back" _goback done
_goback:
Call Foo ;to go back to the previous custom page
done:

FunctionEnd


Thanks Again,


If you want to stay on the current page use Abort in the leave function.


Nope. Want to go back to the previous screen. Foo actually reads in values from Foo.ini.


You can also use Abort in the pre function to stay on the current page.

What exactly are you trying to do? When do you want to go back?


Function Bar LeaveBar
_start:
;If the user forgets to enter input
goto _start
FunctionEnd

Function Foo
_start:
;If the user forgets to enter input
goto _start
Function End

Function LeaveBar
; If the user hit the back button( how do I know this?) Call Foo
;else goto _done
_done:
FunctionEnd

Here Screen 1 inovolves Foo. We are on screen 2 (involving Bar) trying to hit back to get to Screen 1 again...

If the goto _start is not present it works perfectly but this is not an option for me as I want to force the user to enter input.

Thanks,
Malathi


I don't really understand what you mean. Do you want to go back to page 1 when validating page 2? Why?


Nope. What I want to do is to go back to Page 1 whenever the user hits back even if all the entries for the required fields are blank. I'm able to accomplish this for cancel i.e irrespective of the state of the required fields, I'm able to cancel out of the installer by inserting a simple strcmp function. All I want is to do the same for back but I dont know how to get hold of the variable that is populated when the user hits back.

Thanks


The leave function is only called when the user clicks Next.


Ahh..Any other options? All I want to do is
StrCmp $UserHitBack "Back" Call Page1

Problem is I dont know how I can get the variable that the installer stores the value of the back button in...Is it one of the register variables?

Thanks


Please explain exactly what feature you want. If a user clicks Back it will of course go the to previous page. What else do you want?


I think I have this figured out. Thanks for your help. Will let you know how it goes...

Basically, the problem stems from the loop that I'm using to force the user to enter input. Moving the loop to the leave function fixes it.

Thanks,
Malathi