mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[BROWSEUI] Check focus before opening AutoComplete (#7128)
Unexpectedly remaining AutoComplete list is annoying. JIRA issue: CORE-19685 - Add CAutoComplete:: m_bEditHasFocus to watch focus. - Update m_bEditHasFocus on WM_SETFOCUS and WM_KILLFOCUS messages on Edit window procedure. - Don't open AutoComplete list when m_bEditHasFocus was FALSE.
This commit is contained in:
parent
71bed0f5f8
commit
9f68f482c1
2 changed files with 12 additions and 1 deletions
|
@ -338,12 +338,14 @@ LRESULT CAutoComplete::EditWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
return TRUE; // eat
|
return TRUE; // eat
|
||||||
break;
|
break;
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
|
m_bEditHasFocus = TRUE;
|
||||||
break;
|
break;
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
// hide the list if lost focus
|
// hide the list if lost focus
|
||||||
hwndGotFocus = (HWND)wParam;
|
hwndGotFocus = (HWND)wParam;
|
||||||
if (hwndGotFocus != m_hwndEdit && hwndGotFocus != m_hWnd)
|
if (hwndGotFocus != m_hwndEdit && hwndGotFocus != m_hWnd)
|
||||||
HideDropDown();
|
HideDropDown();
|
||||||
|
m_bEditHasFocus = FALSE;
|
||||||
break;
|
break;
|
||||||
case WM_IME_NOTIFY:
|
case WM_IME_NOTIFY:
|
||||||
if (wParam == IMN_OPENCANDIDATE)
|
if (wParam == IMN_OPENCANDIDATE)
|
||||||
|
@ -656,7 +658,7 @@ LRESULT CACSizeBox::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand
|
||||||
// CAutoComplete public methods
|
// CAutoComplete public methods
|
||||||
|
|
||||||
CAutoComplete::CAutoComplete()
|
CAutoComplete::CAutoComplete()
|
||||||
: m_bInSetText(FALSE), m_bInSelectItem(FALSE)
|
: m_bInSetText(FALSE), m_bInSelectItem(FALSE), m_bEditHasFocus(FALSE)
|
||||||
, m_bDowner(TRUE), m_dwOptions(ACO_AUTOAPPEND | ACO_AUTOSUGGEST)
|
, m_bDowner(TRUE), m_dwOptions(ACO_AUTOAPPEND | ACO_AUTOSUGGEST)
|
||||||
, m_bEnabled(TRUE), m_hwndCombo(NULL), m_hFont(NULL), m_bResized(FALSE)
|
, m_bEnabled(TRUE), m_hwndCombo(NULL), m_hFont(NULL), m_bResized(FALSE)
|
||||||
, m_hwndEdit(NULL), m_fnOldEditProc(NULL), m_fnOldWordBreakProc(NULL)
|
, m_hwndEdit(NULL), m_fnOldEditProc(NULL), m_fnOldWordBreakProc(NULL)
|
||||||
|
@ -1121,6 +1123,7 @@ CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL,
|
||||||
if (!::SetWindowSubclass(hwndEdit, EditSubclassProc, 0, reinterpret_cast<DWORD_PTR>(this)))
|
if (!::SetWindowSubclass(hwndEdit, EditSubclassProc, 0, reinterpret_cast<DWORD_PTR>(this)))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
m_hwndEdit = hwndEdit;
|
m_hwndEdit = hwndEdit;
|
||||||
|
m_bEditHasFocus = (::GetFocus() == hwndEdit);
|
||||||
// add reference to m_hwndEdit
|
// add reference to m_hwndEdit
|
||||||
AddRef();
|
AddRef();
|
||||||
// set word break procedure
|
// set word break procedure
|
||||||
|
@ -1387,6 +1390,13 @@ CStringW CAutoComplete::GetQuickEdit(LPCWSTR pszText) const
|
||||||
|
|
||||||
VOID CAutoComplete::RepositionDropDown()
|
VOID CAutoComplete::RepositionDropDown()
|
||||||
{
|
{
|
||||||
|
// If Edit has no focus, don't open auto-complete
|
||||||
|
if (!m_bEditHasFocus)
|
||||||
|
{
|
||||||
|
TRACE("!m_bEditHasFocus\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get nearest monitor from m_hwndEdit
|
// get nearest monitor from m_hwndEdit
|
||||||
HMONITOR hMon = ::MonitorFromWindow(m_hwndEdit, MONITOR_DEFAULTTONEAREST);
|
HMONITOR hMon = ::MonitorFromWindow(m_hwndEdit, MONITOR_DEFAULTTONEAREST);
|
||||||
ATLASSERT(hMon != NULL);
|
ATLASSERT(hMon != NULL);
|
||||||
|
|
|
@ -153,6 +153,7 @@ public:
|
||||||
static LPCWSTR GetWndClassName() { return WC_DROPDOWNW; }
|
static LPCWSTR GetWndClassName() { return WC_DROPDOWNW; }
|
||||||
BOOL m_bInSetText; // this flag avoids subsequent action in WM_SETTEXT
|
BOOL m_bInSetText; // this flag avoids subsequent action in WM_SETTEXT
|
||||||
BOOL m_bInSelectItem; // this flag avoids subsequent action in LVN_ITEMCHANGED
|
BOOL m_bInSelectItem; // this flag avoids subsequent action in LVN_ITEMCHANGED
|
||||||
|
BOOL m_bEditHasFocus;
|
||||||
|
|
||||||
// public methods
|
// public methods
|
||||||
CAutoComplete();
|
CAutoComplete();
|
||||||
|
|
Loading…
Reference in a new issue