Old 17th November 2008, 01:06   #1
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
What's wrong with my Custom Page?

I have been trying to find the cause of the problem in my script - to no avail.

I have a script that works well. But now I want to add to it a custom page that prompts the user to select a folder. Here is the function for that page:


PHP Code:
Var varSelectedFolder  ; global var - defined before any sectionpage or function

LangString PAGE_TITLE ${LANG_ENGLISH"Title"
LangString PAGE_SUBTITLE ${LANG_ENGLISH"Subtitle"

Function PageDirSelect
  
!insertmacro MUI_HEADER_TEXT $(PAGE_TITLE) $(PAGE_SUBTITLE)

  
nsDialogs::SelectFolderDialog /NOUNLOAD "Select Folder" "$DOCUMENTS"
  
Pop $varSelectedFolder    ;where selected folder string is returned

  
Check A Folder Has Been Selected
  
${If} $varSelectedFolder == "error"
    
MessageBox MB_OK "You must select a folder a folder. Aborting."
    
Abort Cancel Installation
  
${Else}
  ${EndIf}
 
  
nsDialogs::Show
FunctionEnd 
The custom page is simply inserted between the version checking (custom) page and the MUI_PAGE_INSTFILES.
PHP Code:
!ifdef VER_MAJOR VER_MINOR VER_REVISION VER_BUILD
  Page custom PageReinstall PageLeaveReinstall
!endif
  
Page custom PageDirSelect 
  
!insertmacro MUI_PAGE_INSTFILES
  
!insertmacro MUI_PAGE_FINISH 
Again, when I comment out the Page custom line, the script works and finishes fine.

But with the Page custom code, the script never reaches the finish page!

This is beyond me. Clearly there is something wrong that I am doing in the custom page function (PageDirSelect). But what is it?

That function is so simple... I am lost.

Any help, clue or insight would be deeply appreciated.

Thanks!

P.S. Is it possible that I need a leave function for this custom page? Must I have a leave function even when a page is that simple? (if so, why?)
nsnb is offline   Reply With Quote
Old 17th November 2008, 18:39   #2
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
Thanks to LoRd_MuldeR, the mystery has been solved: It turns out that the last line in the function (nsDialogs::Show) is the one responsible for ruining everything.

I commented it out and all works now as desired.

Now, my question is one of understanding: Why?

Why, when using nsDialogs::Create in the custom page function, nsDialogs::Show is mandatory, while when using nsDialogs::SelectFolderDialog, nsDialogs::Show must not be used?

Is it because nsDialogs::SelectFolderDialog contains both create() and show() calls?

If so, why would a second show() call would be so devastating to the entire .nsi script?
nsnb is offline   Reply With Quote
Old 17th November 2008, 20:11   #3
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
It's probably because the folder and file browse dialogs are not actually part of the custom page. They are actually separate windows.

Think about it:
Normally you wouldn't expect to see a folder browse dialog until you click a "browse" button.

Therefore, you'd probably want to put it in an onclick function of a button instead of the create function.

Usually, you do this with text box and a browse button. When someone clicks the button and selects a file or folder, you just send a message to update the contents of the text box.
Comperio is offline   Reply With Quote
Old 18th November 2008, 01:03   #4
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
It seems nsDialogs::SelectFolderDialog is a stand-alone function that runs independent of nsDialogs::Create and nsDialogs::Show. Also, as already state by Comperio, that function doesn't actually create a custom page, but shows a popup dialog. The call to nsDialogs::SelectFolderDialog will NOT return, until the user has selected a folder (or has aborted). So there's no need (and no sense) in calling the nsDialogs::Show function after the folder dialog is already done.

In fact it shouldn't even be necessary to call nsDialogs::SelectFolderDialog from a custom page function...

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast 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