- NSIS Discussion
- Program Back/Cancel button
Archive: Program Back/Cancel button
treaz
22nd January 2003 00:55 UTC
Program Back/Cancel button
Hi,
May I know if there is anyway to modify or program the back buttons and the Cancel/Next buttons?
For example I want the installer to do something before going back to the previous page when the user clicks "Back".
Thanks.:)
treaz
22nd January 2003 01:19 UTC
Hi,
Continuation to my above posting...
It would also be nice if someone could advice me on how do I enable my CANCEL button at my Install Page. Currently while my installer is extracting its files, etc, I am unable to stop it half-way by clicking Cancel button because it has been disabled.
Thanks.
virtlink
22nd January 2003 11:20 UTC
The Cancel button is always disabled while installing. This is configured in the NSIS compiler itself.
If you aren't using the Modern UI, you can use the following:
Page license
|components|directory|instfiles ***91;pre_function***93; ***91;post_function***93;
Where you replace [pre_function] with the function name of a function that contains instructions that need to be executed before loading, and [post_function] with the function name of a function that contains instructions that need to be executed after loading.
Taken from: Chapter 3.5.2
kichik
22nd January 2003 15:03 UTC
You can't enable the cancel button yet. I do plan on adding this feature sometime in the future though.
treaz
23rd January 2003 20:36 UTC
May I know then if there is anyway to modify or program the back button?
What I actually wish to do is:
If the user clicks on "BACK" then the installer skips all my functions and checking which I have coded.
Thanks.
:)
virtlink
24th January 2003 13:44 UTC
Look here: http://forums.winamp.com/showthread....hreadid=122389. KiCHiK said two days ago that a feature that would enable to do things at exit of a page would become available tomorrow (yesterday). I haven't heard anything from him about it since.
So I don't know whether KiCHiK implemented a variable or function that can be used to check what button was used. I should be there in order to let what you want work.
kichik
24th January 2003 13:56 UTC
It will only be called when pressing next. Should be available today I hope.
treaz, you should just copy 1 to a variable and before checking check if this variable is 1. If it is, skip your functions. No need to know when the user clicks back, just flag that you have already done the testing.
kichik
24th January 2003 19:43 UTC
Up and running.
treaz
7th March 2003 22:07 UTC
Originally posted by kichik
It will only be called when pressing next. Should be available today I hope.
treaz, you should just copy 1 to a variable and before checking check if this variable is 1. If it is, skip your functions. No need to know when the user clicks back, just flag that you have already done the testing.
May I know how do I verify if the user clicked the BACK button instead of any other button? If I have a way to check, it would solve my problem for sure.
Thanks.:)
kichik
7th March 2003 22:16 UTC
After the function executes copy 1 to a variable and before executing again check if that variable is 1. If the function has already executed it won't execute it again. If really want it only not to execute when pressing back (can't see why, but it's your call) then set that variable in one of the next page's callback functions and have the function that you don't want to execute check for it and unset it after it checked.
treaz
7th March 2003 22:33 UTC
My apologies but I am totally confused by your explanation.
I need to run my check function every time the text boxes get changed. Therefore if I use a variable (to check that once the function has been ran, it does not run again), I will not be able to run my check function again once the user modifies the text boxes.
Not sure if I am making myself clear, cause I seem to have difficulty explaining the senerio.
Thanks.
kichik
7th March 2003 22:36 UTC
I will answer this tomorrow unless someone does before me. Too tired to think :)
treaz
10th March 2003 21:39 UTC
Let me try to explain me scenerio:
I have a customised page that takes in 4 user inputs.
These inputs should be checked only when the user click NEXT.
The checking process: these 4 inputs are passed as arguments into a java class which does the validation. If there is an error, a message box would pop up to tell the user what was wrong with the inputs. The user should be allowed to re-enter the inputs.
I do NOT wish to run the check function upon clicking the BACK button, firstly because the checking takes a very long time. Secondly, because my checking function pops up a message box if the information entered was invalid.
Currently if the input boxes were empty and the user click BACK or even CANCEL, my checking function would run and return an error message to say that an error occurred (because it does not accept empty inputs). BUT this doesn't make sense because the user did not request to move forward with this installation. He merely requested to go BACK.
I wish to know how I can make my above scenerio more sensible.
Any help would be great. Thanks!
Afrow UK
10th March 2003 23:03 UTC
The Check funtion should be called on the next page's pre function.
If using Modern UI and your next page is the InsFiles page, use
!define MUI_CUSTOMFUNCTION_INSTFILES_SHOW "Check"
Where "Check" is your special function.
If you don't use Modern UI, use the
Page InstFiles "Check"
Does that answer your query?
-Stuart
treaz
10th March 2003 23:45 UTC
Hi,
Thanks for your reply.
I have tried that method of putting my check function as the pre function for the next page.
However, I would not be able to return to the previous page automatically if the input given by the users are invalid.
If you have any ideas, I would be more than glad to try it.
Thanks.:)
deguix
11th March 2003 08:02 UTC
If you use Install Options 2, you can do this:
Use this code in the function of your page.
!insertmacro MUI_HEADER_TEXT "TEXT TO TITLE" "TEXT TO SUBTITLE"
#If you use !insertmacro MUI_INSTALLOPTIONS_DISPLAY "inifile.ini"
#replace this by:
Push $R0
InstallOptions
::dialog "$PLUGINSDIR\\inifile.ini"
Pop $R0
#...
StrCmp $R0 "success" 0 EndSuccess
>#Put here the code that you want to run when next button is pressed.
EndSuccess:
>#Put here the code that you want to run when any button is pressed.
treaz
11th March 2003 19:39 UTC
Thanks a lot!
I finally got my problem solved.
That was indeed a very helpful piece of code.
:)
deguix
12th March 2003 08:02 UTC
I viewed the Modern UI documentation and I detected a change in this doc, now this code:
Push $R0
InstallOptions::dialog "$PLUGINSDIR\inifile.ini"
Pop $R0
Can be replaced by:
!insertmacro MUI_INSTALLOPTIONS_DISPLAY_RETURN "inifile.ini"
But I didn't test this, so if you get any problems with this, you can use the old code posted by me before.