Archive: What's wrong with my Custom Page?


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:



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.

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.:confused:

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

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?


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.


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...