X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0b14a7bdfdd022245a9d6487ae98c2382b2ad1d5..91a6c655582321b61a7545ed9c121ad6593ccbfe:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index fd698b0ad0..bf06f72f30 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -392,30 +392,39 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event) if (hit != wxRICHTEXT_HITTEST_NONE) { - wxTextAttrEx attr; - if (GetStyle(position, attr)) + wxRichTextEvent cmdEvent( + wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, + GetId()); + cmdEvent.SetEventObject(this); + cmdEvent.SetPosition(m_caretPosition+1); + + if (!GetEventHandler()->ProcessEvent(cmdEvent)) { - if (attr.HasFlag(wxTEXT_ATTR_URL)) + wxTextAttrEx attr; + if (GetStyle(position, attr)) { - wxString urlTarget = attr.GetURL(); - if (!urlTarget.IsEmpty()) + if (attr.HasFlag(wxTEXT_ATTR_URL)) { - wxMouseEvent mouseEvent(event); - - long startPos = 0, endPos = 0; - wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position); - if (obj) + wxString urlTarget = attr.GetURL(); + if (!urlTarget.IsEmpty()) { - startPos = obj->GetRange().GetStart(); - endPos = obj->GetRange().GetEnd(); - } + wxMouseEvent mouseEvent(event); - wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos); - InitCommandEvent(urlEvent); + long startPos = 0, endPos = 0; + wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position); + if (obj) + { + startPos = obj->GetRange().GetStart(); + endPos = obj->GetRange().GetEnd(); + } - urlEvent.SetString(urlTarget); + wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos); + InitCommandEvent(urlEvent); - GetEventHandler()->ProcessEvent(urlEvent); + urlEvent.SetString(urlTarget); + + GetEventHandler()->ProcessEvent(urlEvent); + } } } } @@ -495,23 +504,45 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) } /// Right-click -void wxRichTextCtrl::OnRightClick(wxMouseEvent& event) +void wxRichTextCtrl::OnRightClick(wxMouseEvent& WXUNUSED(event)) { SetFocus(); - event.Skip(); + + wxRichTextEvent cmdEvent( + wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, + GetId()); + cmdEvent.SetEventObject(this); + cmdEvent.SetPosition(m_caretPosition+1); + + GetEventHandler()->ProcessEvent(cmdEvent); } /// Left-double-click -void wxRichTextCtrl::OnLeftDClick(wxMouseEvent& event) +void wxRichTextCtrl::OnLeftDClick(wxMouseEvent& WXUNUSED(event)) { - SelectWord(GetCaretPosition()+1); - event.Skip(); + wxRichTextEvent cmdEvent( + wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, + GetId()); + cmdEvent.SetEventObject(this); + cmdEvent.SetPosition(m_caretPosition+1); + + if (!GetEventHandler()->ProcessEvent(cmdEvent)) + { + SelectWord(GetCaretPosition()+1); + } } /// Middle-click void wxRichTextCtrl::OnMiddleClick(wxMouseEvent& event) { - event.Skip(); + wxRichTextEvent cmdEvent( + wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, + GetId()); + cmdEvent.SetEventObject(this); + cmdEvent.SetPosition(m_caretPosition+1); + + if (!GetEventHandler()->ProcessEvent(cmdEvent)) + event.Skip(); } /// Key press @@ -1016,7 +1047,7 @@ bool wxRichTextCtrl::ScrollIntoView(long position, int keyCode) // Going down if (keyCode == WXK_DOWN || keyCode == WXK_NUMPAD_DOWN || - keyCode == WXK_RIGHT || keyCode == WXK_NUMPAD_DOWN || + keyCode == WXK_RIGHT || keyCode == WXK_NUMPAD_RIGHT || keyCode == WXK_END || keyCode == WXK_NUMPAD_END || keyCode == WXK_PAGEDOWN || keyCode == WXK_NUMPAD_PAGEDOWN) { @@ -2008,7 +2039,7 @@ wxRichTextCtrl::HitTest(const wxPoint& pt, 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) + else if (hit & (wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_AFTER)) return wxTE_HT_ON_TEXT; return wxTE_HT_UNKNOWN; @@ -2033,30 +2064,21 @@ void wxRichTextCtrl::DoSetValue(const wxString& value, int flags) { Clear(); - // if the text is long enough, it's faster to just set it instead of first - // comparing it with the old one (chances are that it will be different - // anyhow, this comparison is there to avoid flicker for small single-line - // edit controls mostly) - if ( (value.length() > 0x400) || (value != GetValue()) ) + if (!value.IsEmpty()) { + // Remove empty paragraph + GetBuffer().Clear(); DoWriteText(value); // for compatibility, don't move the cursor when doing SetValue() SetInsertionPoint(0); } - else // same text + else { - if ( flags & SetValue_SendEvent ) - { - // still send an event for consistency + // still send an event for consistency + if (flags & SetValue_SendEvent) SendTextUpdatedEvent(); - } } - - // we should reset the modified flag even if the value didn't really change - - // mark the control as being not dirty - we changed its text, not the - // user DiscardEdits(); }