From 09c45e5af87d680512b8c94465e44764cd123090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E5=87=8C=E6=B1=90?= Date: Thu, 19 Dec 2024 16:53:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=A4=B1=E5=8E=BB=E7=84=A6=E7=82=B9=E6=97=B6=E4=BE=9D?= =?UTF-8?q?=E7=84=B6=E6=98=BE=E7=A4=BA=E6=8C=87=E9=92=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Cursor.h | 5 ++++- components/Editor.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/Cursor.h b/components/Cursor.h index d3f0fec..e226a5f 100644 --- a/components/Cursor.h +++ b/components/Cursor.h @@ -90,7 +90,10 @@ public: void onKeyPress(int key) override { return; } - void setVisibility(bool visibility) { visibility_ = visibility; } + void setVisibility(bool visibility) { + if(visibility == visibility_) return; + visibility_ = visibility; + } bool isVisible() { return visibility_; } }; diff --git a/components/Editor.h b/components/Editor.h index 8e075ac..e9bc01e 100644 --- a/components/Editor.h +++ b/components/Editor.h @@ -12,7 +12,7 @@ class Editor : public BaseComponent { private: TextArea textArea_ = TextArea(0, 0, 0, 0); - Cursor cursor_; + Cursor cursor_ = Cursor(0, 0, false); std::string content_; RichText coloredContent_; std::string ruleName_; @@ -120,6 +120,8 @@ public: void setFocus(bool focusStatus) { BaseComponent::setFocus(focusStatus); cursor_.setVisibility(focusStatus); + + draw(); } void onKeyPress(int key) override {