Old 15th September 2011, 15:42   #1
EZsteve
Junior Member
 
Join Date: Sep 2011
Posts: 6
Disable Enter Key

I have a dialog With 3 buttons: Back, Accept and Decline - Within the displayed text there are two links (Not sure if the links are relevant to the question).

Anyway, initially the BACK button is the default:
${NSD_SetText} $mui.Button.Next "&Accept"
${NSD_SetText} $mui.Button.Cancel "&Decline"
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $mui.Button.Back 1

The problem is, if the user CLICKS on either of the links (Or for that matter anywhere in the dialog), the FOCUS (Or default) moves to the ACCEPT button - At which point the user can press ENTER and move forward - The requirement is for them to physically CLICK the ACCEPT button.

Question: How do I: (1) Stop the user from pressing ENTER, or (2) Ensure that clicking within the dialog does not change the default, or even (3) ensure that the BACK button is always the default.
EZsteve is offline   Reply With Quote
Old 15th September 2011, 16:35   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Simple solution: Disable the next button and add a checkbox 'I accept' that enables it.

Proper solution: You need to change the default action from Next to Back. I've no idea how to do this though. (Note that this is very different from setting the focus! Using NEXTDLGCTL you changed the focus, but you did NOT change the default.)
MSG is offline   Reply With Quote
Old 15th September 2011, 18:05   #3
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
You'll want to send DM_SETDEFID (0x0401) to the parent dialog. The wparam will be the control id (not the handle). If you are creating your Accept/Decline/Back buttons on your custom page, the dialog is not HWNDPARENT, it is your inner dialog.
code:
!define DM_SETDEFID 0x0401
SendMessage $HWND ${DM_SETDEFID} $mui.Button.Back.Id 0

demiller9 is offline   Reply With Quote
Old 15th September 2011, 18:23   #4
EZsteve
Junior Member
 
Join Date: Sep 2011
Posts: 6
Hi: MSG, thanks, you pointed me in the RIGHT DIRECTION:

Change the DEFAULT. So I went to RESOURCE HACKER and changed DIALOG 105 of modern.exe to set the BACK BUTTON to BS_DEFPUSHBUTTON - This worked like a charm - Many thanks. HOWEVER, that (Obviously) changes the default throughout the installer. New question: How to change the PROPERTIES of a BUTTON within a function (So that it applies to this one dialog only).

From:
"CONTROL "", 3, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 201, 50, 14"

To:
"CONTROL "", 3, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 201, 50, 14"

Demiller9: Tried that, but that just changed the DEFAULT to the ACCEPT button (Tried it with a "0" and a "1".
EZsteve is offline   Reply With Quote
Old 15th September 2011, 18:39   #5
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
It sounds like you were not using the ID of the Back button - perhaps you used the Accept button's id by accident. The last parameter is unused, so 0/1 would not help.
demiller9 is offline   Reply With Quote
Old 15th September 2011, 19:12   #6
EZsteve
Junior Member
 
Join Date: Sep 2011
Posts: 6
Demiller9, you are right, I was not using the ID - I hate to ask (Especially since it seem like I know what I am doing by doing stuff in Resource Hacker).....................But I am relatively new to NSIS - How do I find out the ID assigned to each button?
EZsteve is offline   Reply With Quote
Old 15th September 2011, 22:07   #7
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
If you are using MUI2, the IDs of your controls start at 1200 and go up for each control (checkbox, label, groupbox, radio button, etc) you create. You can also find several 'spy' type programs that will let you drag a crosshair onto the control and will show you the id.
demiller9 is offline   Reply With Quote
Old 15th September 2011, 22:37   #8
EZsteve
Junior Member
 
Join Date: Sep 2011
Posts: 6
Thank you so much for your help. Through a series of your help and a bit of luck I have it working. The trick was to add your code:

!define DM_SETDEFID 0x0401
SendMessage $HWND ${DM_SETDEFID} $mui.Button.Back.3 0

Change the $HWND to $HWNDPARENT:

SendMessage $HWNDPARENT ${DM_SETDEFID} $mui.Button.Back.3 0

And THEN reset FOCUS to the BACK button:

SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $mui.Button.Back 1.

So the complete solution is:

!define DM_SETDEFID 0x0401
SendMessage $HWNDPARENT ${DM_SETDEFID} $mui.Button.Back.3 0
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $mui.Button.Back 1

I sure hope this helps somebody else - I know it drove me mad!

PS. Is there a way to mark this issue as solved?
EZsteve is offline   Reply With Quote
Old 16th September 2011, 04:40   #9
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
(There's no way to mark this 'issue' solved, and there's no need to. Forum threads aren't issues, they're discussions.)
MSG is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
disable enter key, maintain default button

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