From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102727 invoked by alias); 9 Dec 2017 13:11:10 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 102709 invoked by uid 9795); 9 Dec 2017 13:11:10 -0000 Date: Sat, 09 Dec 2017 13:11:00 -0000 Message-ID: <20171209131110.102681.qmail@sourceware.org> From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.882-16-ga7c7dea X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: c3853939020aeb5bfc5b4995cd604da4ce3f72cc X-Git-Newrev: a7c7dea653e9e5ccfe702a8d25dbcbd82a7f0beb X-SW-Source: 2017-q4/txt/msg00046.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=a7c7dea653e9e5ccfe702a8d25dbcbd82a7f0beb commit a7c7dea653e9e5ccfe702a8d25dbcbd82a7f0beb Author: Ken Brown Date: Tue Dec 5 12:21:12 2017 -0500 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. We don't change the default control immediately on EN_SETFOCUS unless there is already text in the search textbox, so pressing 'enter' with the focus on the search textbox (the initial state of the dialog) without typing anything into the search textbox moves to the next page, as previously. Also improve a bit of debug output from ChooserPage::OnMessageCmd() v2: Explicitly add/remove the defpushbutton style from the "Next" button when the default button changes v3: Refine behaviour so default control is changed on EN_SETFOCUS if some search text is present. Diff: --- choose.cc | 39 ++++++++++++++++++++++++++++++++++++--- res.rc | 2 ++ resource.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/choose.cc b/choose.cc index 1bc4c0b..c78f55d 100644 --- a/choose.cc +++ b/choose.cc @@ -381,12 +381,38 @@ 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); + HWND nextButton = ::GetDlgItem(::GetParent(GetHWND()), 0x3024 /* ID_WIZNEXT */); + char buf[16]; + + if ((code == EN_CHANGE) || + ((code == EN_SETFOCUS) && GetWindowText(GetDlgItem(IDC_CHOOSE_SEARCH_EDIT), buf, 15))) + { + // when focus arrives at this control and it has some text in it, or + // when we change the text in it, change the default button to one + // which immediately applies the search filter + // + // (we don't do this when the focus is on this control but it's empty + // (the initial state of the dialog) so that enter in that state moves + // onto the next page) + SendMessage(GetHWND (), DM_SETDEFID, (WPARAM) IDC_CHOOSE_DO_SEARCH, 0); + SendMessage(nextButton, BM_SETSTYLE, BS_PUSHBUTTON, TRUE); + } + if (code == EN_CHANGE) + { + // apply the search filter when we stop typing + SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL); + } + else if (code == EN_KILLFOCUS) + { + // when focus leaves this control, restore the normal default button + SendMessage(GetHWND (), DM_SETDEFID, (WPARAM) 0x3024 /* ID_WIZNEXT */, 0); + SendMessage(nextButton, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE); + } return true; } else if (code == BN_CLICKED) @@ -402,6 +428,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