mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CtrlLib: RichTextView WhenLeftClick, ClearSelection
This commit is contained in:
parent
143ad0aa3d
commit
dc53ff972d
3 changed files with 11 additions and 4 deletions
|
|
@ -14,7 +14,6 @@ public:
|
|||
virtual void LeftTriple(Point p, dword keyflags);
|
||||
virtual void RightDown(Point p, dword keyflags);
|
||||
virtual String GetSelectionData(const String& fmt) const;
|
||||
virtual void LostFocus();
|
||||
|
||||
private:
|
||||
Rect margin;
|
||||
|
|
@ -55,6 +54,7 @@ protected:
|
|||
public:
|
||||
Event<const String&> WhenLink;
|
||||
Event<int> WhenMouseMove;
|
||||
Event<> WhenLeftClick;
|
||||
|
||||
void Clear();
|
||||
void Pick(RichText&& t);
|
||||
|
|
@ -81,6 +81,7 @@ public:
|
|||
int GetLength() const { return text.GetLength(); }
|
||||
|
||||
bool IsSelection() const { return anchor != cursor; }
|
||||
void ClearSelection();
|
||||
void Copy();
|
||||
|
||||
void ScrollUp() { sb.PrevLine(); }
|
||||
|
|
|
|||
|
|
@ -208,10 +208,12 @@ void RichTextView::RefreshSel()
|
|||
SetSelectionSource(ClipFmtsText());
|
||||
}
|
||||
|
||||
void RichTextView::LostFocus()
|
||||
void RichTextView::ClearSelection()
|
||||
{
|
||||
anchor = cursor;
|
||||
RefreshSel();
|
||||
if(IsSelection()) {
|
||||
anchor = cursor;
|
||||
RefreshSel();
|
||||
}
|
||||
}
|
||||
|
||||
void RichTextView::LeftDown(Point p, dword keyflags)
|
||||
|
|
@ -232,6 +234,7 @@ void RichTextView::LeftDown(Point p, dword keyflags)
|
|||
SetFocus();
|
||||
SetCapture();
|
||||
}
|
||||
WhenLeftClick();
|
||||
}
|
||||
|
||||
void RichTextView::LeftDouble(Point p, dword keyflags)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ RichTextCtrlSelection::RichTextCtrlSelection()
|
|||
CtrlLayout(*this, "Window title");
|
||||
a <<= "This is some text";
|
||||
b <<= "This is another text";
|
||||
|
||||
a.WhenLeftClick = [=] { b.ClearSelection(); };
|
||||
b.WhenLeftClick = [=] { a.ClearSelection(); };
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue