mirror of https://github.com/axmolengine/axmol.git
Detect CTRL+A key combination to select all text in EditBox (#2251)
* Detect CTRL+A key combination to select all text in EditBox * Ensure EditBox has focus before checking for CTRL+A combination
This commit is contained in:
parent
57c3e6c1c2
commit
1e8fbb991d
|
@ -73,7 +73,6 @@ EditBoxImpl* __createSystemEditBox(EditBox* pEditBox)
|
|||
|
||||
EditBoxImplWin::EditBoxImplWin(EditBox* pEditText)
|
||||
: EditBoxImplCommon(pEditText)
|
||||
, _hotKeyIdCtrlA(0)
|
||||
, _hwndEdit(NULL)
|
||||
, _changedTextManually(false)
|
||||
, _hasFocus(false)
|
||||
|
@ -101,10 +100,6 @@ void EditBoxImplWin::cleanupEditCtrl()
|
|||
{
|
||||
if (_hwndEdit)
|
||||
{
|
||||
UnregisterHotKey(_hwndEdit, _hotKeyIdCtrlA);
|
||||
GlobalDeleteAtom(_hotKeyIdCtrlA);
|
||||
_hotKeyIdCtrlA = 0;
|
||||
|
||||
SetWindowLongPtrW(_hwndEdit, GWLP_WNDPROC, (LONG_PTR)_prevWndProc);
|
||||
::DestroyWindow(_hwndEdit);
|
||||
_hasFocus = false;
|
||||
|
@ -137,9 +132,6 @@ void EditBoxImplWin::createEditCtrl(bool singleLine)
|
|||
s_previousFocusWnd = s_hwndCocos;
|
||||
this->setNativeFont(this->getNativeDefaultFontName(), this->_fontSize);
|
||||
this->setNativeText(this->_text.c_str());
|
||||
|
||||
_hotKeyIdCtrlA = GlobalAddAtom(L"CTRL+A");
|
||||
RegisterHotKey(_hwndEdit, _hotKeyIdCtrlA, MOD_CONTROL | MOD_NOREPEAT, 'A');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,6 +305,12 @@ void EditBoxImplWin::_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
if (_hasFocus && wParam == 'A' && (GetKeyState(VK_CONTROL) & 0x8000) != 0) // CTRL+A for "Select All"
|
||||
{
|
||||
::SendMessageW(_hwndEdit, EM_SETSEL, 0, -1);
|
||||
}
|
||||
break;
|
||||
case WM_CHAR:
|
||||
if (wParam == VK_RETURN)
|
||||
{
|
||||
|
@ -369,12 +367,6 @@ void EditBoxImplWin::_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
this->editBoxEditingDidEnd(this->getText(), _endAction);
|
||||
}
|
||||
break;
|
||||
case WM_HOTKEY:
|
||||
if (wParam == (WPARAM)_hotKeyIdCtrlA)
|
||||
{
|
||||
::SendMessageW(_hwndEdit, EM_SETSEL, 0, -1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@ private:
|
|||
void _WindowProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
WNDPROC _prevWndProc;
|
||||
ATOM _hotKeyIdCtrlA;
|
||||
|
||||
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
static LRESULT CALLBACK hookGLFWWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
|
Loading…
Reference in New Issue