- NSIS Discussion
- Programmatically return back to the previuos page
Archive: Programmatically return back to the previuos page
chocho_rock
22nd January 2003 17:34 UTC
Programmatically return back to the previuos page
Hi everybody.
I'd like to obtain the following behaviour with NSIS 2.0 beta 0:
When the user clicks "Next" on the directory choosing page, the path is verified (maybe in the next page creation function)
and if it is not valid, a warning is displayed and the directory choosing page is displayed again.
I'm not able to obtain it because in the creation callback function of a custom page it is not possible to return back to the previous page, but only to skip the current one with Abort.
I can not user .onVerifyInstDir because it's called while the user is typing, and I don't like this behaviour.. as I said I'd like to check the path when the "next" button is pressed.
Anyone can help please?
Thanks
Chocho
virtlink
22nd January 2003 18:08 UTC
Look here and use the post_function to check wether the path is valid. If not, use 'abort'.
kichik
22nd January 2003 18:09 UTC
Post function is called just before the page is shown, not after. I am working right now on a function that will do that because a lot of people requested it and because it will solve the radio buttons/checkbox on the license page problem.
virtlink
22nd January 2003 18:12 UTC
Gosh, never used it, so... :D
Then it will propably become:
Page license|directory|etc... [preshow_function] [postshow_function] [onleave_function]
(chocho_rock, before copying my line here, this won't work yet!)
kichik
22nd January 2003 18:14 UTC
Precreate, preshow, and preleave.
kichik
22nd January 2003 20:06 UTC
OK, I have finished this, but I want to test it a bit so I will release it only tomorrow.
danno6000
31st January 2003 21:23 UTC
PreLeave funtionality on a custom page
Is the preleave funtionality going to be implemented for a custom page?
kichik
1st February 2003 11:32 UTC
I am sorry, I forgot to let you know. It's already available in the latest CVS version.
danno6000
3rd February 2003 12:52 UTC
Looking at code
After looking at the latest code, I don't see how to implement the 'preleave' function for a custom page. It only seems to be dealt with for the non-custom pages.
I don't know if it's a typo or not, but lines 785-788 in script.cpp look like they may not do what was inteded. Both of these 'if' statements set p.showfunc. Should the second one set p.leavefunc?
kichik
3rd February 2003 13:53 UTC
Pre-leave function was not designed to work with custom pages, but now that I look at it again, it should. I'll add this in a couple of days.
Those lines indeed contain a typo. Thanks.
treaz
7th March 2003 22:05 UTC
Hi,
I was just wondering if the Pre-leave function is now available for custom pages?
Thanks.
:)
kichik
7th March 2003 22:06 UTC
Oops... Thanks for reminding me. It's now in the todo list where I won't miss it ;)
Joel
7th March 2003 22:31 UTC
This means, now the installer can return to a previuos page automatically?
How? someone have a script example? :)
Sunjammer
8th March 2003 09:54 UTC
No it's *not* available yet. KiCHiK added it to the CVS file TODO.txt so that he knows it needs to be done and won't be forgotten.
kichik
8th March 2003 11:09 UTC
Well, actually it's only not available for custom pages. For normal pages just use the leave callback function. If you call Abort from that function it won't leave the page.
kichik
18th March 2003 15:51 UTC
Ready and waiting in CVS. Use NSIS Update to get it.
mlm
22nd April 2003 06:53 UTC
Is there any example code for the leave function in a custom page?
Afrow UK
22nd April 2003 11:34 UTC
This will work.
Use like so...
Page Custom CustomPage
Function CustomPage
top:
InstallOptions::dialog "$PLUGINSDIR\IO1.ini"
ReadINIStr $R0 "$PLUGINSDIR\IO1.ini" "Field 2" "State"
IfFileExists $R0\*.* done
MessageBox MB_OK|MB_ICONEXCLAMATION "The entered installtion path is invalid."
Goto top
done:
FunctionEnd
-Stu
kichik
22nd April 2003 12:39 UTC
Your example doens't use the new leave callback function. Contrib\InstallOptions\test.nsi contains such an example.
mlm
23rd April 2003 04:07 UTC
I think I'm confused. What exactly is the leave callback function. Can you use it in a .nsi script? Or do you have to edit the C code?
Afrow UK, I was able to use the code you posted. It does exactly what I want, but I would still like to know what the leave callback is.
thanks for all the help!
mlm (aka, digitalda)
mlm
23rd April 2003 06:42 UTC
I'm having some problems. I tried to implement the above suggestion and I thought it was working, but now when I try to cancel before making a selection it forces me to make a selection before canceling.
Function SetIDE
MakeSelection:
!insertmacro MUI_HEADER_TEXT "Choose your IDE" ""
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "SetIDE.ini"
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "SetIDE.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "SetIDE.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "SetIDE.ini" "Field 4" "State"
StrCmp $R1 "1" "Done" ""
StrCmp $R2 "1" "Done" ""
StrCmp $R3 "1" "Done" ""
MessageBox MB_OK|MB_iconexclamation "Please select your IDE."
Goto MakeSelection
Done:
>FunctionEnd
>
any suggestions?
virtlink
23rd April 2003 09:39 UTC
A callback function is a function that is called when a particular event occures. The normal Page-instruction syntax is this:
Page (license|components|directory|instfiles) ***91;pre_function***93; ***91;show_function***93; ***91;leave_function***93;
[pre_function] is replaced by the name of the function that is called before showing the page.
[show_function] is replaced by the name of the function that should be called after creating the page's components, but before showing it (allows some UI tweaking).
[leave_function] is replaced by the name of the function that is called just before the page is made invisible, but after the 'Next' button is clicked.
Something similar now exists for Custom pages:
Page custom***91;creator_function***93; ***91;leave_function***93; ***91;caption***93;
[creator_function] is replaced by the name of the function which contains the custom page creating script (InstallOptions::dialog "$PLUGINSDIR\IO.ini").
[leave_function] is replaced by the name of the function that is called just before the page is made invisible, but after the 'Next' button of the custom page is clicked.
This allows something like this (not tested):
Page custom CustomPageCreate CustomPageLeave
>Function CustomPageCreate
GetTempFileName $R0
File/oname=$R0 customPage.ini
InstallOptions
::dialog $R0
FunctionEnd
>Function CustomPageLeave
MessageBox MB_YES"Do you want to leave the custom page?" IDYES yes
Abort
yes:
>FunctionEnd
>