X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/136cb3c7a9fff4252c2bb48aac5db124f8dc3ce0..6cc687bfee071b5328f9e48d1708795287006bb7:/src/msw/textctrl.cpp?ds=sidebyside diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index b5a07c4239..cee29ac19e 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -357,10 +357,16 @@ void wxTextCtrl::AdoptAttributesFromHWND() WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const { + // default border for the text controls is the sunken one + if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) + { + style |= wxBORDER_SUNKEN; + } + long msStyle = wxControl::MSWGetStyle(style, exstyle); // default styles - msStyle |= ES_LEFT | WS_TABSTOP; + msStyle |= ES_LEFT; if ( style & wxTE_MULTILINE ) { @@ -686,6 +692,25 @@ void wxTextCtrl::Clear() ::SetWindowText(GetHwnd(), wxT("")); } +#ifdef __WIN32__ + +bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& event) +{ + SetFocus(); + + size_t lenOld = GetValue().length(); + + wxUint32 code = event.GetRawKeyCode(); + ::keybd_event(code, 0, 0 /* key press */, NULL); + ::keybd_event(code, 0, KEYEVENTF_KEYUP, NULL); + + // assume that any alphanumeric key changes the total number of characters + // in the control - this should work in 99% of cases + return GetValue().length() != lenOld; +} + +#endif // __WIN32__ + // ---------------------------------------------------------------------------- // Clipboard operations // ---------------------------------------------------------------------------- @@ -838,6 +863,12 @@ void wxTextCtrl::GetSelection(long* from, long* to) const bool wxTextCtrl::IsEditable() const { + // strangely enough, we may be called before the control is created: our + // own Create() calls MSWGetStyle() which calls AcceptsFocus() which calls + // us + if ( !m_hWnd ) + return TRUE; + long style = ::GetWindowLong(GetHwnd(), GWL_STYLE); return (style & ES_READONLY) == 0; @@ -1477,7 +1508,6 @@ bool wxTextCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *re ::SetCursor(GetHcursorOf(wxCursor(wxCURSOR_HAND))); *result = TRUE; break; - case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: