Merge branch 'focus_hwnd'
Fix focus handling in wxMSW wxSpinCtrl: select all the text when it gets focus as expected. See https://github.com/wxWidgets/wxWidgets/pull/1627
This commit is contained in:
@@ -77,7 +77,6 @@ public:
|
|||||||
virtual int GetValue() const wxOVERRIDE;
|
virtual int GetValue() const wxOVERRIDE;
|
||||||
virtual void SetRange(int minVal, int maxVal) wxOVERRIDE;
|
virtual void SetRange(int minVal, int maxVal) wxOVERRIDE;
|
||||||
virtual bool SetFont(const wxFont &font) wxOVERRIDE;
|
virtual bool SetFont(const wxFont &font) wxOVERRIDE;
|
||||||
virtual void SetFocus() wxOVERRIDE;
|
|
||||||
|
|
||||||
virtual bool Enable(bool enable = true) wxOVERRIDE;
|
virtual bool Enable(bool enable = true) wxOVERRIDE;
|
||||||
virtual bool Show(bool show = true) wxOVERRIDE;
|
virtual bool Show(bool show = true) wxOVERRIDE;
|
||||||
@@ -115,6 +114,8 @@ public:
|
|||||||
|
|
||||||
virtual void SetLayoutDirection(wxLayoutDirection dir) wxOVERRIDE;
|
virtual void SetLayoutDirection(wxLayoutDirection dir) wxOVERRIDE;
|
||||||
|
|
||||||
|
virtual WXHWND MSWGetFocusHWND() const wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoGetPosition(int *x, int *y) const wxOVERRIDE;
|
virtual void DoGetPosition(int *x, int *y) const wxOVERRIDE;
|
||||||
virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE;
|
virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE;
|
||||||
|
@@ -168,6 +168,12 @@ public:
|
|||||||
void AssociateHandle(WXWidget handle) wxOVERRIDE;
|
void AssociateHandle(WXWidget handle) wxOVERRIDE;
|
||||||
void DissociateHandle() wxOVERRIDE;
|
void DissociateHandle() wxOVERRIDE;
|
||||||
|
|
||||||
|
// returns the handle of the native window to focus when this wxWindow gets
|
||||||
|
// focus (i.e. in composite windows: by default, this is just the HWND for
|
||||||
|
// this window itself, but it can be overridden to return something
|
||||||
|
// different for composite controls
|
||||||
|
virtual WXHWND MSWGetFocusHWND() const { return GetHWND(); }
|
||||||
|
|
||||||
// does this window have deferred position and/or size?
|
// does this window have deferred position and/or size?
|
||||||
bool IsSizeDeferred() const;
|
bool IsSizeDeferred() const;
|
||||||
|
|
||||||
|
@@ -522,6 +522,13 @@ void wxSpinCtrl::SetLayoutDirection(wxLayoutDirection dir)
|
|||||||
SetSize(-1, -1, -1, -1, wxSIZE_AUTO | wxSIZE_FORCE);
|
SetSize(-1, -1, -1, -1, wxSIZE_AUTO | wxSIZE_FORCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WXHWND wxSpinCtrl::MSWGetFocusHWND() const
|
||||||
|
{
|
||||||
|
// Return the buddy hwnd because it shuld be focused instead of the
|
||||||
|
// wxSpinCtrl itself.
|
||||||
|
return m_hwndBuddy;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxSpinButton methods
|
// wxSpinButton methods
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -653,11 +660,6 @@ bool wxSpinCtrl::Enable(bool enable)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinCtrl::SetFocus()
|
|
||||||
{
|
|
||||||
::SetFocus(GetBuddyHwnd());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
|
|
||||||
void wxSpinCtrl::DoSetToolTip(wxToolTip *tip)
|
void wxSpinCtrl::DoSetToolTip(wxToolTip *tip)
|
||||||
|
@@ -577,7 +577,7 @@ void wxWindowMSW::SetId(wxWindowID winid)
|
|||||||
|
|
||||||
void wxWindowMSW::SetFocus()
|
void wxWindowMSW::SetFocus()
|
||||||
{
|
{
|
||||||
HWND hWnd = GetHwnd();
|
HWND hWnd = (HWND)MSWGetFocusHWND();
|
||||||
wxCHECK_RET( hWnd, wxT("can't set focus to invalid window") );
|
wxCHECK_RET( hWnd, wxT("can't set focus to invalid window") );
|
||||||
|
|
||||||
::SetLastError(0);
|
::SetLastError(0);
|
||||||
@@ -599,13 +599,15 @@ void wxWindowMSW::SetFocus()
|
|||||||
|
|
||||||
void wxWindowMSW::SetFocusFromKbd()
|
void wxWindowMSW::SetFocusFromKbd()
|
||||||
{
|
{
|
||||||
|
HWND hWnd = (HWND)MSWGetFocusHWND();
|
||||||
|
|
||||||
// when the focus is given to the control with DLGC_HASSETSEL style from
|
// when the focus is given to the control with DLGC_HASSETSEL style from
|
||||||
// keyboard its contents should be entirely selected: this is what
|
// keyboard its contents should be entirely selected: this is what
|
||||||
// ::IsDialogMessage() does and so we should do it as well to provide the
|
// ::IsDialogMessage() does and so we should do it as well to provide the
|
||||||
// same LNF as the native programs
|
// same LNF as the native programs
|
||||||
if ( ::SendMessage(GetHwnd(), WM_GETDLGCODE, 0, 0) & DLGC_HASSETSEL )
|
if ( ::SendMessage(hWnd, WM_GETDLGCODE, 0, 0) & DLGC_HASSETSEL )
|
||||||
{
|
{
|
||||||
::SendMessage(GetHwnd(), EM_SETSEL, 0, -1);
|
::SendMessage(hWnd, EM_SETSEL, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do this after (maybe) setting the selection as like this when
|
// do this after (maybe) setting the selection as like this when
|
||||||
|
Reference in New Issue
Block a user