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

Jon Turney jon.turney@dronecode.org.uk
Thu Dec 7 18:35:00 GMT 2017


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.

> 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.

I'm a bit puzzled that IDD_SITE apparently doesn't need anything to do 
that, but IDD_CHOOSE does...
-------------- next part --------------
From c403b87ac035c9d7678a60764e0f39cbaf85c435 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 5 Dec 2017 12:21:12 -0500
Subject: [PATCH setup] Fix response to enter in the chooser search textbox

Make 'enter' after we've started typing into the search textbox cause the
search filter to immediately take effect.

Note that we don't change the default control immediately on EN_SETFOCUS,
but wait for ENCHANGE, so pressing 'enter' before typing anything into the
search textbox still moves to the next page.

Also improve a bit of debug output from ChooserPage::OnMessageCmd()
---
 choose.cc  | 20 +++++++++++++++++---
 res.rc     |  2 ++
 resource.h |  1 +
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/choose.cc b/choose.cc
index 1bc4c0b..4219a81 100644
--- a/choose.cc
+++ b/choose.cc
@@ -381,12 +381,19 @@ bool
 ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
 {
 #if DEBUG
-  Log (LOG_BABBLE) << "OnMesageCmd " << id << " " << hwndctl << " " << code << endLog;
+  Log (LOG_BABBLE) << "OnMessageCmd " << id << " " << hwndctl << " " << std::hex << code << endLog;
 #endif
 
-  if (code == EN_CHANGE && id == IDC_CHOOSE_SEARCH_EDIT)
+  if (id == IDC_CHOOSE_SEARCH_EDIT)
     {
-      SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL);
+      if (code == EN_CHANGE)
+        {
+          SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) IDC_CHOOSE_DO_SEARCH, 0);
+          SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL);
+        }
+      else if (code == EN_KILLFOCUS)
+        SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) 0x3024 /* ID_WIZNEXT */, 0);
+
       return true;
     }
   else if (code == BN_CLICKED)
@@ -402,6 +409,13 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
       }
       break;
 
+    case IDC_CHOOSE_DO_SEARCH:
+      // invisible pushbutton which is the default pushbutton while typing into
+      // the search textbox, so that 'enter' causes the filter to be applied
+      // immediately, rather than activating the next page
+      SendMessage (GetHWND (), WM_TIMER, (WPARAM) timer_id, 0);
+      break;
+
     case IDC_CHOOSE_KEEP:
       if (IsButtonChecked (id))
         keepClicked();
diff --git a/res.rc b/res.rc
index a4d7e70..901cf76 100644
--- a/res.rc
+++ b/res.rc
@@ -342,6 +342,8 @@ BEGIN
                     CBS_DROPDOWNLIST | WS_TABSTOP
     RTEXT           "&Search", IDC_STATIC, SETUP_SEARCH_X, 33, SETUP_SEARCH_W,
                     10, SS_CENTERIMAGE, WS_EX_RIGHT
+    CONTROL         "Search ", IDC_CHOOSE_DO_SEARCH, "Button", BS_PUSHBUTTON | NOT
+                    WS_VISIBLE, SETUP_SEARCH_X, 33, SETUP_SEARCH_W, 14
     EDITTEXT        IDC_CHOOSE_SEARCH_EDIT, SETUP_SEARCHTEXT_X, 30,
                     SETUP_SEARCHTEXT_W, 14, ES_AUTOHSCROLL
     PUSHBUTTON      "&Clear", IDC_CHOOSE_CLEAR_SEARCH, SETUP_CLEAR_X, 30,
diff --git a/resource.h b/resource.h
index a2e867f..79b876d 100644
--- a/resource.h
+++ b/resource.h
@@ -177,3 +177,4 @@
 #define IDC_FILE_INUSE_HELP               592
 #define IDC_NET_DIRECT_LEGACY             593
 #define IDC_DOWNLOAD_EDIT                 594
+#define IDC_CHOOSE_DO_SEARCH              595
-- 
2.15.1



More information about the Cygwin-apps mailing list