]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
Don't capture the mouse until after the possible wxEVT_GRID_CELL_BEGIN_DRAG event.
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index 749eba3829617a3dc30f5153b7dd7ce5ba2801c6..006122f0ae111ddbe5bbb7113bedaefa0311ddfa 100644 (file)
@@ -74,6 +74,7 @@ BEGIN_EVENT_TABLE( wxRichTextCtrl, wxControl )
     EVT_SIZE(wxRichTextCtrl::OnSize)
     EVT_SET_FOCUS(wxRichTextCtrl::OnSetFocus)
     EVT_KILL_FOCUS(wxRichTextCtrl::OnKillFocus)
+    EVT_MOUSE_CAPTURE_LOST(wxRichTextCtrl::OnCaptureLost)
     EVT_CONTEXT_MENU(wxRichTextCtrl::OnContextMenu)
 
     EVT_MENU(wxID_UNDO, wxRichTextCtrl::OnUndo)
@@ -325,6 +326,11 @@ void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event))
     //    Refresh(false);
 }
 
+void wxRichTextCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
+{
+    m_dragging = false;    
+}
+
 /// Left-click
 void wxRichTextCtrl::OnLeftClick(wxMouseEvent& event)
 {
@@ -432,7 +438,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
     // See if we need to change the cursor
     
     {
-        if (hit != wxRICHTEXT_HITTEST_NONE)
+        if (hit != wxRICHTEXT_HITTEST_NONE & !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
         {
             wxTextAttrEx attr;
             if (GetStyle(position, attr))
@@ -447,6 +453,8 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
                 }
             }
         }
+        else
+            SetCursor(m_textCursor);
     }
 
     if (!event.Dragging())
@@ -1325,7 +1333,7 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags)
         // we want to be at the end of the last line but with m_caretAtLineStart set to true,
         // so we view the caret at the start of the line.
         bool caretLineStart = false;
-        if (hitTest == wxRICHTEXT_HITTEST_BEFORE)
+        if (hitTest & wxRICHTEXT_HITTEST_BEFORE)
         {
             wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1);
             wxRichTextRange lineRange;
@@ -1969,17 +1977,14 @@ wxRichTextCtrl::HitTest(const wxPoint& pt,
 
     int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos);
 
-    switch ( hit )
-    {
-        case wxRICHTEXT_HITTEST_BEFORE:
-            return wxTE_HT_BEFORE;
-
-        case wxRICHTEXT_HITTEST_AFTER:
-            return wxTE_HT_BEYOND;
-
-        case wxRICHTEXT_HITTEST_ON:
-            return wxTE_HT_ON_TEXT;
-    }
+    if ((hit & wxRICHTEXT_HITTEST_BEFORE) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
+        return wxTE_HT_BEFORE;
+    else if ((hit & wxRICHTEXT_HITTEST_AFTER) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
+        return wxTE_HT_BEYOND;
+    else if (hit & wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_AFTER)
+        return wxTE_HT_ON_TEXT;
+    else
+        return wxTE_HT_UNKNOWN;
 
     return wxTE_HT_UNKNOWN;
 }