فهرست منبع

LibGUI: Expose a function to clear GTextEditor selection

Sasan Hezarkhani 5 سال پیش
والد
کامیت
5c2ef01f7b
2فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  1. 8 0
      Libraries/LibGUI/GTextEditor.cpp
  2. 1 0
      Libraries/LibGUI/GTextEditor.h

+ 8 - 0
Libraries/LibGUI/GTextEditor.cpp

@@ -1223,6 +1223,14 @@ void GTextEditor::set_selection(const GTextRange& selection)
     update();
     update();
 }
 }
 
 
+void GTextEditor::clear_selection()
+{
+    if (!has_selection())
+        return;
+    m_selection.clear();
+    update();
+}
+
 void GTextEditor::recompute_all_visual_lines()
 void GTextEditor::recompute_all_visual_lines()
 {
 {
     int y_offset = 0;
     int y_offset = 0;

+ 1 - 0
Libraries/LibGUI/GTextEditor.h

@@ -69,6 +69,7 @@ public:
     bool has_selection() const { return m_selection.is_valid(); }
     bool has_selection() const { return m_selection.is_valid(); }
     String selected_text() const;
     String selected_text() const;
     void set_selection(const GTextRange&);
     void set_selection(const GTextRange&);
+    void clear_selection();
     bool can_undo() const { return document().can_undo(); }
     bool can_undo() const { return document().can_undo(); }
     bool can_redo() const { return document().can_redo(); }
     bool can_redo() const { return document().can_redo(); }