[PATCH 12/17] shell32/autocomplete: Fix handling of Return key when an auto-suggestion item is selected
Gabriel Ivăncescu
gabrielopcode at gmail.com
Wed Sep 5 11:13:14 CDT 2018
When selecting an item from the AutoComplete's listbox, the Return key
should act the same as a left click on it (place the text, select it,
and hide the listbox). This matches Windows behavior.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
Also fixes quickComplete since apparently a VK_RETURN is sent as a WM_CHAR of
'\n' when CTRL is pressed.
dlls/shell32/autocomplete.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 1678d87..449e8a4 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -67,8 +67,10 @@ typedef struct
IAutoComplete2 IAutoComplete2_iface;
IAutoCompleteDropDown IAutoCompleteDropDown_iface;
LONG ref;
- BOOL initialized;
- BOOL enabled;
+ BOOLEAN initialized;
+ BOOLEAN enabled;
+ UCHAR no_fwd_char;
+ AUTOCOMPLETEOPTIONS options;
HWND hwndEdit;
HWND hwndListBox;
WNDPROC wpOrigEditProc;
@@ -76,7 +78,6 @@ typedef struct
WCHAR *txtbackup;
WCHAR *quickComplete;
IEnumString *enumstr;
- AUTOCOMPLETEOPTIONS options;
} IAutoCompleteImpl;
static const WCHAR autocomplete_propertyW[] = {'W','i','n','e',' ','A','u','t','o',
@@ -177,14 +178,32 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
break;
sz *= 2;
}
+
+ This->no_fwd_char = '\n'; /* CTRL+RETURN char */
if (This->options & ACO_AUTOSUGGEST)
ShowWindow(This->hwndListBox, SW_HIDE);
heap_free(hwndText);
return 0;
}
- if (This->options & ACO_AUTOSUGGEST)
+ if (This->options & ACO_AUTOSUGGEST) {
+ if (IsWindowVisible(This->hwndListBox)) {
+ HWND hwndListBox = This->hwndListBox;
+ sel = send_to_LB(This, hwndListBox, LB_GETCURSEL, 0, 0);
+ if (sel >= 0) {
+ len = send_to_LB(This, hwndListBox, LB_GETTEXTLEN, sel, 0);
+ if ((hwndText = heap_alloc((len + 1)*sizeof(WCHAR)))) {
+ len = send_to_LB(This, hwndListBox, LB_GETTEXT, sel, (LPARAM)hwndText);
+ set_text_and_selection(This, hwnd, hwndText, 0, len);
+ This->no_fwd_char = '\r'; /* RETURN char */
+ ShowWindow(hwndListBox, SW_HIDE);
+ heap_free(hwndText);
+ return 0;
+ }
+ }
+ }
ShowWindow(This->hwndListBox, SW_HIDE);
+ }
break;
case VK_UP:
case VK_DOWN:
@@ -232,9 +251,14 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
goto handle_control_char;
}
+ This->no_fwd_char = '\0';
return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
case WM_CHAR:
case WM_UNICHAR:
+ if (wParam == This->no_fwd_char)
+ return 0;
+ This->no_fwd_char = '\0';
+
ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
if (wParam < ' ')
{
--
1.9.1
More information about the wine-devel
mailing list