X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d7eaf91403705cdd94acaae0d7413e711cce3dc..cc57f388d769cba09debd611d1e5e5f6d28aee41:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 80d59be6ff..b414fa7bb5 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtext/richeditctrl.cpp +// Name: src/richtext/richeditctrl.cpp // Purpose: A rich edit control // Author: Julian Smart // Modified by: @@ -13,7 +13,7 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ - #pragma hdrstop + #pragma hdrstop #endif #if wxUSE_RICHTEXT @@ -21,12 +21,12 @@ #include "wx/richtext/richtextctrl.h" #ifndef WX_PRECOMP - #include "wx/wx.h" + #include "wx/wx.h" + #include "wx/settings.h" #endif #include "wx/textfile.h" #include "wx/ffile.h" -#include "wx/settings.h" #include "wx/filename.h" #include "wx/dcbuffer.h" #include "wx/arrimpl.cpp" @@ -429,13 +429,21 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) event.GetKeyCode() == WXK_HOME || event.GetKeyCode() == WXK_PAGEUP || event.GetKeyCode() == WXK_PAGEDOWN || - event.GetKeyCode() == WXK_PRIOR || - event.GetKeyCode() == WXK_NEXT || event.GetKeyCode() == WXK_END) { KeyboardNavigate(event.GetKeyCode(), flags); + return; } - else if (event.GetKeyCode() == WXK_RETURN) + + // all the other keys modify the controls contents which shouldn't be + // possible if we're read-only + if ( !IsEditable() ) + { + event.Skip(); + return; + } + + if (event.GetKeyCode() == WXK_RETURN) { BeginBatchUndo(_("Insert Text")); @@ -529,10 +537,6 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) SetDefaultStyleToCursorStyle(); ScrollIntoView(m_caretPosition, WXK_RIGHT); } -#if 0 - else - event.Skip(); -#endif } /// Delete content if there is a selection, e.g. when pressing a key. @@ -618,11 +622,11 @@ bool wxRichTextCtrl::KeyboardNavigate(int keyCode, int flags) else success = MoveDown(1, flags); } - else if (keyCode == WXK_PAGEUP || keyCode == WXK_PRIOR) + else if (keyCode == WXK_PAGEUP) { success = PageUp(1, flags); } - else if (keyCode == WXK_PAGEDOWN || keyCode == WXK_NEXT) + else if (keyCode == WXK_PAGEDOWN) { success = PageDown(1, flags); } @@ -716,7 +720,7 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode) wxSize clientSize = GetClientSize(); // Going down - if (keyCode == WXK_DOWN || keyCode == WXK_RIGHT || keyCode == WXK_END || keyCode == WXK_NEXT || keyCode == WXK_PAGEDOWN) + if (keyCode == WXK_DOWN || keyCode == WXK_RIGHT || keyCode == WXK_END || keyCode == WXK_PAGEDOWN) { if ((rect.y + rect.height) > (clientSize.y + startY)) { @@ -746,7 +750,7 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode) } } // Going up - else if (keyCode == WXK_UP || keyCode == WXK_LEFT || keyCode == WXK_HOME || keyCode == WXK_PRIOR || keyCode == WXK_PAGEUP) + else if (keyCode == WXK_UP || keyCode == WXK_LEFT || keyCode == WXK_HOME || keyCode == WXK_PAGEUP ) { if (rect.y < startY) { @@ -1581,17 +1585,20 @@ wxString wxRichTextCtrl::GetStringSelection() const } // do the window-specific processing after processing the update event +#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE void wxRichTextCtrl::DoUpdateWindowUI(wxUpdateUIEvent& event) { - if ( event.GetSetEnabled() ) - Enable(event.GetEnabled()); + // call inherited + wxWindowBase::DoUpdateWindowUI(event); + // update text if ( event.GetSetText() ) { if ( event.GetText() != GetValue() ) SetValue(event.GetText()); } } +#endif // !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE // ---------------------------------------------------------------------------- // hit testing @@ -2530,4 +2537,3 @@ long wxRichTextCtrl::GetFirstVisiblePosition() const #endif // wxUSE_RICHTEXT -