- NSIS Discussion
- Back Button not working properly
Archive: Back Button not working properly
mj_igx
8th April 2004 00:56 UTC
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.
deguix
8th April 2004 11:16 UTC
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.
Joost Verburg
8th April 2004 13:26 UTC
Using the leave function is easier.
mj_igx
8th April 2004 17:06 UTC
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
Joost Verburg
8th April 2004 17:25 UTC
Page custom Foo leaveFoo
mj_igx
13th April 2004 00:04 UTC
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
mj_igx
14th April 2004 18:50 UTC
Just wonderinf if anyone has answers to the question that I posted...
Thanks.
Joost Verburg
14th April 2004 19:09 UTC
You mean the text of the button? See the language file for the language string name.
mj_igx
14th April 2004 19:35 UTC
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,
Joost Verburg
14th April 2004 19:37 UTC
If you want to stay on the current page use Abort in the leave function.
mj_igx
14th April 2004 19:43 UTC
Nope. Want to go back to the previous screen. Foo actually reads in values from Foo.ini.
Joost Verburg
14th April 2004 20:21 UTC
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?
mj_igx
14th April 2004 21:17 UTC
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
Joost Verburg
14th April 2004 22:01 UTC
I don't really understand what you mean. Do you want to go back to page 1 when validating page 2? Why?
mj_igx
14th April 2004 22:10 UTC
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
Joost Verburg
14th April 2004 22:13 UTC
The leave function is only called when the user clicks Next.
mj_igx
14th April 2004 22:24 UTC
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
Joost Verburg
15th April 2004 09:52 UTC
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?
mj_igx
21st April 2004 22:46 UTC
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