[PATCH setup] Make Enter in the user URL box cause ADD instead of NEXT

Jon Turney jon.turney@dronecode.org.uk
Fri Dec 8 15:48:00 GMT 2017


On 07/12/2017 20:46, Ken Brown wrote:
> On 12/7/2017 1:35 PM, Jon Turney wrote:
>> On 05/12/2017 17:32, Ken Brown wrote:
>>> On 12/5/2017 11:03 AM, Ken Brown wrote:
>>>> On 12/5/2017 7:58 AM, Jon Turney wrote:
>>>>> The search textbox on the package chooser page needs the same fix.
>>>>
>>>> It's not immediately clear to me how to do this, since I don't know 
>>>> what the default pushbutton should be while the user is typing in 
>>>> the search box.
>>>>
>>>> One possibility is to convert the label "Search" to the left of the 
>>>> box to a SEARCH pushbutton, whose effect is to call 
>>>> OnTimerMessage(). If we make this the default, then pressing Enter 
>>>> will cause the search filter to immediately take effect, which is 
>>>> probably what the user expects.
>>
>> It seems a bit weird to have a button which automatically pushes 
>> itself half a second after you finish typing.
>>
>> Attached is my attempt, which (ab)uses an invisible button.
> 
> I agree, this is better than my version.
> 
>>> Something like the attached?  This might not be quite right, because 
>>> the previous default button is never restored.  I'm not sure how 
>>> important that is.
>>
>> I think it's something that should be done, if possible, so I added that.
> 
> In my testing, 'Next' does indeed become the default button after I 
> click outside of the textbox, but there's no visual indication of this.

This is interesting: if you use TAB to move the focus out of the 
textbox, then first "Clear" gets highlight (because it's a pushbutton 
and enter pushes it), TAB again and "Current is selected (but "Next" 
gets the highlight, because that's what enter pushes)

If you click to move the focus, it only seems to update the highlight 
the second time you do that.

Which I guess suggests we should be ensuring the highlight is drawn on 
EN_KILLFOCUS?

But once I do that, it seems I need to explicitly remove as well, which 
gives the attached, incremental patch.
-------------- next part --------------
From 4308c448d33e5de993586a4573f6810efdd26bbf Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Fri, 8 Dec 2017 15:44:03 +0000
Subject: [PATCH setup] Explicitly remove defpushbutton style from "Next"
 button when not default

---
 choose.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/choose.cc b/choose.cc
index 4219a81..d7265cb 100644
--- a/choose.cc
+++ b/choose.cc
@@ -27,6 +27,7 @@
    default. */
 
 #include "win32.h"
+#include "windowsx.h"
 #include <commctrl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -386,14 +387,19 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
 
   if (id == IDC_CHOOSE_SEARCH_EDIT)
     {
+      HWND nextButton = ::GetDlgItem(::GetParent(GetHWND()), 0x3024 /* ID_WIZNEXT */);
+
       if (code == EN_CHANGE)
         {
           SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) IDC_CHOOSE_DO_SEARCH, 0);
+          Button_SetStyle(nextButton, BS_PUSHBUTTON, TRUE);
           SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL);
         }
       else if (code == EN_KILLFOCUS)
-        SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) 0x3024 /* ID_WIZNEXT */, 0);
-
+        {
+          SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) 0x3024 /* ID_WIZNEXT */, 0);
+          Button_SetStyle(nextButton, BS_DEFPUSHBUTTON, TRUE);
+        }
       return true;
     }
   else if (code == BN_CLICKED)
-- 
2.15.1



More information about the Cygwin-apps mailing list