Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 22nd January 2003, 16:34   #1
chocho_rock
Junior Member
 
Join Date: Jan 2003
Posts: 1
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
chocho_rock is offline   Reply With Quote
Old 22nd January 2003, 17:08   #2
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
Look here and use the post_function to check wether the path is valid. If not, use 'abort'.

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 22nd January 2003, 17:09   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

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 22nd January 2003, 17:12   #4
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
Gosh, never used it, so...

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!)

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 22nd January 2003, 17:14   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Precreate, preshow, and preleave.

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 22nd January 2003, 19:06   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
OK, I have finished this, but I want to test it a bit so I will release it only tomorrow.

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 January 2003, 20:23   #7
danno6000
Junior Member
 
Join Date: Jan 2003
Posts: 2
PreLeave funtionality on a custom page

Is the preleave funtionality going to be implemented for a custom page?
danno6000 is offline   Reply With Quote
Old 1st February 2003, 10:32   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
I am sorry, I forgot to let you know. It's already available in the latest CVS version.

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 3rd February 2003, 11:52   #9
danno6000
Junior Member
 
Join Date: Jan 2003
Posts: 2
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?
danno6000 is offline   Reply With Quote
Old 3rd February 2003, 12:53   #10
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

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 7th March 2003, 21:05   #11
treaz
Member
 
Join Date: Jan 2003
Posts: 78
Hi,

I was just wondering if the Pre-leave function is now available for custom pages?

Thanks.
treaz is offline   Reply With Quote
Old 7th March 2003, 21:06   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Oops... Thanks for reminding me. It's now in the todo list where I won't miss it

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 7th March 2003, 21:31   #13
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,896
This means, now the installer can return to a previuos page automatically?
How? someone have a script example?


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux w/ xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Debian unstable w/ xfce4.
Joel is offline   Reply With Quote
Old 8th March 2003, 08:54   #14
Sunjammer
Major Dude
 
Join Date: Jun 2002
Location: Swindon, UK
Posts: 559
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.
Sunjammer is offline   Reply With Quote
Old 8th March 2003, 10:09   #15
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
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.

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 18th March 2003, 14:51   #16
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Ready and waiting in CVS. Use NSIS Update to get it.

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 22nd April 2003, 05:53   #17
mlm
Junior Member
 
Join Date: Apr 2003
Posts: 8
Is there any example code for the leave function in a custom page?
mlm is offline   Reply With Quote
Old 22nd April 2003, 10:34   #18
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
This will work.
Use like so...

Page Custom CustomPage

code:

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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 22nd April 2003, 11:39   #19
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
Your example doens't use the new leave callback function. Contrib\InstallOptions\test.nsi contains such an example.

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 23rd April 2003, 03:07   #20
mlm
Junior Member
 
Join Date: Apr 2003
Posts: 8
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 is offline   Reply With Quote
Old 23rd April 2003, 05:42   #21
mlm
Junior Member
 
Join Date: Apr 2003
Posts: 8
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.

PHP Code:
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?
mlm is offline   Reply With Quote
Old 23rd April 2003, 08:39   #22
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
A callback function is a function that is called when a particular event occures. The normal Page-instruction syntax is this:
PHP Code:
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:
PHP Code:
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):
PHP Code:
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 

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Reply
Go Back   Winamp 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