GetBuffer().Reset();
GetBuffer().SetRichTextCtrl(this);
-
+
SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16));
GetCaret()->Show();
wxRichTextCtrl::~wxRichTextCtrl()
{
GetBuffer().RemoveEventHandler(this);
-
+
delete m_contextMenu;
}
void wxRichTextCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
{
- m_dragging = false;
+ m_dragging = false;
}
/// Left-click
long position = 0;
wxPoint logicalPt = event.GetLogicalPosition(dc);
int hit = GetBuffer().HitTest(dc, logicalPt, position);
-
+
if (hit != wxRICHTEXT_HITTEST_NONE)
{
wxTextAttrEx attr;
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);
}
}
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))
{
// Generate conventional event
wxCommandEvent textEvent(wxEVT_COMMAND_TEXT_ENTER, GetId());
InitCommandEvent(textEvent);
-
+
GetEventHandler()->ProcessEvent(textEvent);
}
Update();
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())
switch ( keycode )
{
case WXK_ESCAPE:
- // case WXK_SPACE:
case WXK_DELETE:
case WXK_START:
case WXK_LBUTTON:
case WXK_NUMPAD_SEPARATOR:
case WXK_NUMPAD_SUBTRACT:
case WXK_NUMPAD_DECIMAL:
+ case WXK_WINDOWS_LEFT:
{
event.Skip();
return;
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
SetDefaultStyleToCursorStyle();
ScrollIntoView(m_caretPosition, WXK_RIGHT);
-
+
GetEventHandler()->ProcessEvent(cmdEvent);
Update();
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;
}