Skip to content
⌘ NSIS Forum Archive

How to know that button was pressed?

5 posts

Kalakom#

How to know that button was pressed?

Hello ...


!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leavePageComponents
!insertmacro MUI_PAGE_COMPONENTS
...
...
Function leavePageComponents

MessageBox MB_ICONEXCLAMATION|MB_OK "Hello ..."
FunctionEnd
Function "leavePageComponents" is called when I press to "Next" button and press to "Back" button. I don't want the operator "MessageBox" was called when I press to "Back" button. If I will can to know what pressed "Back" button I will call operator "Return" after this and resolve my problem.
Anders#
Leave is not called there when you press the back button so I don't understand what you are talking about.
Kalakom#
Ok, I did mistake. not "Back" button - use "Cancel" button.
Please, compile this example and press button "Cancel" on component page.

!include "UMUI.nsh"
!insertmacro MUI_PAGE_WELCOME

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leavePageComponents
!insertmacro MUI_PAGE_COMPONENTS

!insertmacro MUI_PAGE_FINISH
!insertmacro UMUI_PAGE_ABORT
!insertmacro MUI_LANGUAGE "Russian"

Section
SectionEnd

Function leavePageComponents
MessageBox MB_ICONEXCLAMATION|MB_OK "Hello ..."
FunctionEnd
Anders#
Official NSIS MUI 1&2 will not display that MessageBox on cancel, I don't know what UMUI does...
Kalakom#
Ok. But the error of NSIS we may bypass. For this in begin function leavePageComponents we can know for what reason this function was called. Or because of press on "Next" button, or because of press on "Cancel" button. If we know that because of press on "Cancel" button we just call Return from the function. How I can know that button "Cancel" was pressed?