From 88bee7e621cb3cf7bc63cb82b1439c2290b51bb6 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 20 Feb 2007 07:57:54 +0000 Subject: [PATCH] Ignore Windows key git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextctrl.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 55b8433ad6..2f4ac745e7 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -141,7 +141,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va GetBuffer().Reset(); GetBuffer().SetRichTextCtrl(this); - + SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16)); GetCaret()->Show(); @@ -194,7 +194,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va wxRichTextCtrl::~wxRichTextCtrl() { GetBuffer().RemoveEventHandler(this); - + delete m_contextMenu; } @@ -328,7 +328,7 @@ void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event)) void wxRichTextCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) { - m_dragging = false; + m_dragging = false; } /// Left-click @@ -390,7 +390,7 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event) long position = 0; wxPoint logicalPt = event.GetLogicalPosition(dc); int hit = GetBuffer().HitTest(dc, logicalPt, position); - + if (hit != wxRICHTEXT_HITTEST_NONE) { wxTextAttrEx attr; @@ -402,20 +402,20 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event) if (!urlTarget.IsEmpty()) { wxMouseEvent mouseEvent(event); - + long startPos = 0, endPos = 0; wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position); if (obj) { startPos = obj->GetRange().GetStart(); endPos = obj->GetRange().GetEnd(); - } - + } + wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos); InitCommandEvent(urlEvent); urlEvent.SetString(urlTarget); - + GetEventHandler()->ProcessEvent(urlEvent); } } @@ -434,9 +434,9 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) long position = 0; wxPoint logicalPt = event.GetLogicalPosition(dc); int hit = GetBuffer().HitTest(dc, logicalPt, position); - + // See if we need to change the cursor - + { if (hit != wxRICHTEXT_HITTEST_NONE && !(hit & wxRICHTEXT_HITTEST_OUTSIDE)) { @@ -590,7 +590,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) // Generate conventional event wxCommandEvent textEvent(wxEVT_COMMAND_TEXT_ENTER, GetId()); InitCommandEvent(textEvent); - + GetEventHandler()->ProcessEvent(textEvent); } Update(); @@ -598,7 +598,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) else if (event.GetKeyCode() == WXK_BACK) { BeginBatchUndo(_("Delete Text")); - + // Submit range in character positions, which are greater than caret positions, // so subtract 1 for deleted character and add 1 for conversion to character position. if (m_caretPosition > -1 && !HasSelection()) @@ -670,7 +670,6 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) switch ( keycode ) { case WXK_ESCAPE: - // case WXK_SPACE: case WXK_DELETE: case WXK_START: case WXK_LBUTTON: @@ -764,6 +763,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) case WXK_NUMPAD_SEPARATOR: case WXK_NUMPAD_SUBTRACT: case WXK_NUMPAD_DECIMAL: + case WXK_WINDOWS_LEFT: { event.Skip(); return; @@ -784,7 +784,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) cmdEvent.SetFlags(flags); cmdEvent.SetCharacter((wxChar) keycode); cmdEvent.SetPosition(m_caretPosition+1); - + if (keycode == wxT('\t')) { // See if we need to promote or demote the selection or paragraph at the cursor @@ -821,7 +821,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) SetDefaultStyleToCursorStyle(); ScrollIntoView(m_caretPosition, WXK_RIGHT); - + GetEventHandler()->ProcessEvent(cmdEvent); Update(); @@ -2681,6 +2681,10 @@ bool wxRichTextCtrl::GetCaretPositionForIndex(long position, wxRect& rect) if (GetBuffer().FindPosition(dc, position, pt, & height, m_caretAtLineStart)) { + // Caret height can't be zero + if (height == 0) + height = dc.GetCharHeight(); + rect = wxRect(pt, wxSize(wxRICHTEXT_DEFAULT_CARET_WIDTH, height)); return true; } -- 2.45.2