text controls respect wxTE_PROCESS_ENTER/TAB styles again, WM_GETDLGCODE

handling is generally better


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2827 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-19 00:08:58 +00:00
parent d220ae3237
commit 101f488cf5
4 changed files with 41 additions and 29 deletions

View File

@@ -181,7 +181,6 @@ public:
virtual void AdoptAttributesFromHWND(); virtual void AdoptAttributesFromHWND();
virtual void SetupColours(); virtual void SetupColours();
virtual long MSWGetDlgCode();
protected: protected:
#if wxUSE_RICHEDIT #if wxUSE_RICHEDIT

View File

@@ -296,12 +296,12 @@ public:
bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam); bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam);
bool HandleCtlColor(WXHBRUSH *hBrush, bool HandleCtlColor(WXHBRUSH *hBrush,
WXHDC hdc, WXHDC hdc,
WXHWND hWnd, WXHWND hWnd,
WXUINT nCtlColor, WXUINT nCtlColor,
WXUINT message, WXUINT message,
WXWPARAM wParam, WXWPARAM wParam,
WXLPARAM lParam); WXLPARAM lParam);
bool HandlePaletteChanged(WXHWND hWndPalChange); bool HandlePaletteChanged(WXHWND hWndPalChange);
bool HandleQueryNewPalette(); bool HandleQueryNewPalette();
@@ -385,6 +385,9 @@ protected:
WXHMENU m_hMenu; // Menu, if any WXHMENU m_hMenu; // Menu, if any
// the return value of WM_GETDLGCODE handler
long m_lDlgCode;
// implement the base class pure virtuals // implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const; virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoScreenToClient( int *x, int *y ) const;

View File

@@ -151,6 +151,21 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if (m_windowStyle & wxTE_PASSWORD) // hidden input if (m_windowStyle & wxTE_PASSWORD) // hidden input
msStyle |= ES_PASSWORD; msStyle |= ES_PASSWORD;
// we always want the characters and the arrows
m_lDlgCode = DLGC_WANTCHARS | DLGC_WANTARROWS;
// we may have several different cases:
// 1. normal case: both TAB and ENTER are used for dialog navigation
// 2. ctrl which wants TAB for itself: ENTER is used to pass to the next
// control in the dialog
// 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation
// 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to
// the next control
if ( m_windowStyle & wxTE_PROCESS_ENTER )
m_lDlgCode |= DLGC_WANTMESSAGE;
if ( m_windowStyle & wxTE_PROCESS_TAB )
m_lDlgCode |= DLGC_WANTTAB;
const wxChar *windowClass = _T("EDIT"); const wxChar *windowClass = _T("EDIT");
#if wxUSE_RICHEDIT #if wxUSE_RICHEDIT
@@ -1123,26 +1138,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
event.Skip(); event.Skip();
} }
long wxTextCtrl::MSWGetDlgCode()
{
// we always want the characters and the arrows
long lRc = DLGC_WANTCHARS | DLGC_WANTARROWS;
// we may have several different cases:
// 1. normal case: both TAB and ENTER are used for dialog navigation
// 2. ctrl which wants TAB for itself: ENTER is used to pass to the next
// control in the dialog
// 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation
// 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to
// the next control
if ( m_windowStyle & wxTE_PROCESS_ENTER )
lRc |= DLGC_WANTMESSAGE;
if ( m_windowStyle & wxTE_PROCESS_TAB )
lRc |= DLGC_WANTTAB;
return lRc;
}
bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{ {
switch (param) switch (param)

View File

@@ -317,6 +317,20 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
msflags |= WS_BORDER; msflags |= WS_BORDER;
} }
// calculate the value to return from WM_GETDLGCODE handler
if ( GetWindowStyleFlag() & wxWANTS_CHARS )
{
// want everything: i.e. all keys and WM_CHAR message
m_lDlgCode = DLGC_WANTARROWS | DLGC_WANTCHARS |
DLGC_WANTTAB | DLGC_WANTMESSAGE;
}
else
{
// default behaviour
m_lDlgCode = 0;
}
MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL, MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
pos.x, pos.y, pos.x, pos.y,
WidthDefault(size.x), HeightDefault(size.y), WidthDefault(size.x), HeightDefault(size.y),
@@ -1756,11 +1770,12 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
break; break;
case WM_GETDLGCODE: case WM_GETDLGCODE:
if ( GetWindowStyleFlag() & wxWANTS_CHARS ) if ( m_lDlgCode )
{ {
rc.result = DLGC_WANTARROWS | DLGC_WANTCHARS | DLGC_WANTTAB; rc.result = m_lDlgCode;
processed = TRUE; processed = TRUE;
} }
//else: get the dlg code from the DefWindowProc()
break; break;
case WM_KEYDOWN: case WM_KEYDOWN: