Archive: how to change behaviour of back button?


how to change behaviour of back button?
  hello. :)

I am hoping that somehow, it would be possible to change the behaviour of the back button.

I am using the back button (with BackButtonText=Help in the .ini file) in an InstallOptions page, as a 'Help' button.

When the user clicks on 'Help' I launch a readme via execwait, but when the readme closes, the installer goes to the license page (which comes before the custom installoptions page). I know that this is the correct behaviour, because the user did press 'back' after all.

But i really wish to make back button not do this, i have tried putting abort into license page, but this causes license page to be skipped when help button is pressed, it is even worse for what i want.

I hope some solution is possible. (please! ;))


thank you. :)


I just wanted to say that I am checking the return value from installoptions for 'back', but i don't know what i can do when i detect 'back' was pressed to stay on the current (installoptions) page.


Page custom [creator_function] [leave_function] [caption]...
You can use the leave_function to detect the variable (use $0 to $9 or custom ones) given by your page, and use abort, to go back to the page. Like this:


Page custom "YourCustomPage" "Help"


>Function Help

># Return the page result to the variable $9

StrCmp $9 "back" 0 Continue

ExecWait "Readme.txt"
Abort

Continue:

>FunctionEnd
>

Thank you deguix! :)

I am testing your suggetion right now, but i thought I tried this already and it didn't work. :|

According to the docs:

the leave-function is called right after the user has pressed the next button and before the page is left
So it sounds like the leave function is not called when 'back' is pressed. :(

But i will try. :)

update: It looks like the docs were right (they usually are :)) the leave function is not being called when back is pressed.)

Maybe there's something I could do in the license page's pre function to skip to the next page (which would be the page I didn't want to leave in the first place, lol).

You best bet probably lies with this plug-in. It will also allow the user to actually go back :)

You can also just call InstallOptions again if it returned "back". NSIS will only use the last button clicked and the user will have to click next or cancel eventually.


Oh yes, DrO's plugin - i was going to do that kichik but for the NT4 crash. :| (I did search the forums first - yay for me. :))

I am intrigued by your other option... so I could do something like:

show_helppage:
InstallOptions::dialog "help_page.ini"
Pop $R9
.
.
.
StrCmp $R9 "back" 0
ExecWait '$PLUGINSDIR\readme.html'
Goto show_helppage
.
.
.
I will try that. :)

Thank you. :)

update: I tested Kichik's suggestion. Of course, it worked!! :D

Kichik == life saver. (Even more than the docs.;))

Yes, that should work except for the ExecWait part. An HTML file is not executable, you should use ExecShell. I would also not recommend waiting for the readme to close because that will cause the page to flicker. If you don't wait for it, the flicker will occur behind the scenes while the user is reading the readme.


Of course. Thank you Kichik, I was being very hasty, I appreciate that you pointed out my mistakes. :)


was it a txt or html file that you were trying to show?

haven't had much chance to work on the code - almost tracked down the NT issue (got it to crash at a fixed point in memory, not the hook proceedure anymore at least)

i was considering adding in reading a txt/rtf file from a specified file instead of being defined in the script. may even look at getting a html file correctly displayed in the window (thinks of the trouble in coding it :D )

-daz