a simpler fix of textctrl key doubling bug

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2029 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-04-02 22:08:39 +00:00
parent 7708abe9cd
commit 391364946e
2 changed files with 22 additions and 54 deletions

View File

@@ -443,7 +443,7 @@ long wxTextCtrl::GetLastPosition() const
// This gets the char index for the _beginning_ of the last line // This gets the char index for the _beginning_ of the last line
int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)(noLines-1), (LPARAM)0L); int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)(noLines-1), (LPARAM)0L);
// Get number of characters in the last line. We'll add this to the character // Get number of characters in the last line. We'll add this to the character
// index for the last line, 1st position. // index for the last line, 1st position.
int lineLength = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0L); int lineLength = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0L);
@@ -457,7 +457,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
HWND hWnd = (HWND) GetHWND(); HWND hWnd = (HWND) GetHWND();
long fromChar = from; long fromChar = from;
long toChar = to; long toChar = to;
// Set selection and remove it // Set selection and remove it
#ifdef __WIN32__ #ifdef __WIN32__
SendMessage(hWnd, EM_SETSEL, fromChar, toChar); SendMessage(hWnd, EM_SETSEL, fromChar, toChar);
@@ -481,7 +481,7 @@ void wxTextCtrl::Remove(long from, long to)
HWND hWnd = (HWND) GetHWND(); HWND hWnd = (HWND) GetHWND();
long fromChar = from; long fromChar = from;
long toChar = to; long toChar = to;
// Cut all selected text // Cut all selected text
#ifdef __WIN32__ #ifdef __WIN32__
SendMessage(hWnd, EM_SETSEL, fromChar, toChar); SendMessage(hWnd, EM_SETSEL, fromChar, toChar);
@@ -504,7 +504,7 @@ void wxTextCtrl::SetSelection(long from, long to)
fromChar = 0; fromChar = 0;
toChar = -1; toChar = -1;
} }
#ifdef __WIN32__ #ifdef __WIN32__
SendMessage(hWnd, EM_SETSEL, (WPARAM)fromChar, (LPARAM)toChar); SendMessage(hWnd, EM_SETSEL, (WPARAM)fromChar, (LPARAM)toChar);
SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0); SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
@@ -659,7 +659,7 @@ void wxTextCtrl::DiscardEdits()
* Some of the following functions are yet to be implemented * Some of the following functions are yet to be implemented
* *
*/ */
int wxTextCtrl::GetNumberOfLines() const int wxTextCtrl::GetNumberOfLines() const
{ {
return (int)SendMessage((HWND) GetHWND(), EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0); return (int)SendMessage((HWND) GetHWND(), EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0);
@@ -705,7 +705,7 @@ void wxTextCtrl::ShowPosition(long pos)
int currentLineLineNo = (int)SendMessage(hWnd, EM_GETFIRSTVISIBLELINE, (WPARAM)0, (LPARAM)0L); int currentLineLineNo = (int)SendMessage(hWnd, EM_GETFIRSTVISIBLELINE, (WPARAM)0, (LPARAM)0L);
int specifiedLineLineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0L); int specifiedLineLineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0L);
int linesToScroll = specifiedLineLineNo - currentLineLineNo; int linesToScroll = specifiedLineLineNo - currentLineLineNo;
if (linesToScroll != 0) if (linesToScroll != 0)
@@ -732,7 +732,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
/* /*
* Text item * Text item
*/ */
void wxTextCtrl::Command(wxCommandEvent & event) void wxTextCtrl::Command(wxCommandEvent & event)
{ {
SetValue (event.GetString()); SetValue (event.GetString());
@@ -752,7 +752,7 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers // AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
//========================================================================= //=========================================================================
// Called then the buffer is full (gcc 2.6.3) // Called then the buffer is full (gcc 2.6.3)
// or when "endl" is output (Borland 4.5) // or when "endl" is output (Borland 4.5)
//========================================================================= //=========================================================================
// Class declaration using multiple inheritance doesn't work properly for // Class declaration using multiple inheritance doesn't work properly for
@@ -770,7 +770,7 @@ int wxTextCtrl::overflow(int c)
return EOF; return EOF;
} }
#endif #endif
// Verify that there are no characters in get area // Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() ) if ( gptr() && gptr() < egptr() )
{ {
@@ -955,26 +955,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
switch( event.KeyCode() ) switch( event.KeyCode() )
{ {
// VZ: commented out until somebody explains to me what it does
#if 0
// Fix by Marcel Rasche to allow Alt-Ctrl insertion of special characters
case '{':
case '}':
case '[':
case ']':
case '|':
case '~':
case '\\':
{
char c = (char)event.KeyCode();
WriteText(c);
}
break;
#endif // 0
case WXK_RETURN: case WXK_RETURN:
{ if ( !(m_windowStyle & wxTE_MULTILINE) )
if ( (m_windowStyle & wxTE_MULTILINE) == 0 )
{ {
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this ); event.SetEventObject( this );
@@ -984,7 +966,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
//else: multiline controls need Enter for themselves //else: multiline controls need Enter for themselves
break; break;
}
case WXK_TAB: case WXK_TAB:
// only produce navigation event if we don't process TAB ourself or // only produce navigation event if we don't process TAB ourself or
@@ -999,7 +980,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
eventNav.SetDirection(!event.ShiftDown()); eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(FALSE); eventNav.SetWindowChange(FALSE);
eventNav.SetEventObject(this); eventNav.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(eventNav) ) if ( GetEventHandler()->ProcessEvent(eventNav) )
return; return;
} }
@@ -1007,8 +988,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
default: default:
event.Skip(); event.Skip();
return;
} }
// don't just call event.Skip() because this will cause TABs and ENTERs // don't just call event.Skip() because this will cause TABs and ENTERs
// be passed upwards and we don't always want this - instead process it // be passed upwards and we don't always want this - instead process it
// right here // right here
@@ -1032,7 +1014,7 @@ long wxTextCtrl::MSWGetDlgCode()
lRc |= DLGC_WANTMESSAGE; lRc |= DLGC_WANTMESSAGE;
if ( m_windowStyle & wxTE_PROCESS_TAB ) if ( m_windowStyle & wxTE_PROCESS_TAB )
lRc |= DLGC_WANTTAB; lRc |= DLGC_WANTTAB;
return lRc; return lRc;
} }

View File

@@ -2038,27 +2038,23 @@ long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
long wxWindow::Default() long wxWindow::Default()
{ {
// Ignore 'fake' events (perhaps generated as a result of a separate real event) // Ignore 'fake' events (perhaps generated as a result of a separate real
if (m_lastMsg == 0) // event)
if ( m_lastMsg == 0 )
return 0; return 0;
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.", wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.",
wxGetMessageName(m_lastMsg)); wxGetMessageName(m_lastMsg));
#endif // __WXDEBUG__ #endif // __WXDEBUG__
long ret = this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam); return MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
// The idea here is to prevent MSWDefWindowProc from being called twice,
// which it can be where OnChar/OnKeyDown are concerned (because OnChar is
// sometimes called in wxWin where it isn't in MSW)
m_lastMsg = 0;
return ret;
} }
bool wxWindow::MSWProcessMessage(WXMSG* pMsg) bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
{ {
if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) ) { if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) )
{
// intercept dialog navigation keys // intercept dialog navigation keys
MSG *msg = (MSG *)pMsg; MSG *msg = (MSG *)pMsg;
bool bProcess = TRUE; bool bProcess = TRUE;
@@ -3790,17 +3786,7 @@ WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
void wxWindow::OnChar(wxKeyEvent& event) void wxWindow::OnChar(wxKeyEvent& event)
{ {
bool isVirtual; event.Skip();
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
if ( id == -1 )
id= m_lastWParam;
if ( !event.ControlDown() ) // Why this test?
{
if (m_lastMsg != 0)
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
}
} }
void wxWindow::OnKeyDown(wxKeyEvent& event) void wxWindow::OnKeyDown(wxKeyEvent& event)