aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls/TextHostControlService.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui/controls/TextHostControlService.hpp')
-rw-r--r--include/cru/ui/controls/TextHostControlService.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/cru/ui/controls/TextHostControlService.hpp b/include/cru/ui/controls/TextHostControlService.hpp
index 6ebe2a27..5216827b 100644
--- a/include/cru/ui/controls/TextHostControlService.hpp
+++ b/include/cru/ui/controls/TextHostControlService.hpp
@@ -15,6 +15,10 @@ class TextRenderObject;
class ScrollRenderObject;
} // namespace cru::ui::render
+namespace cru::ui::components {
+class PopupMenu;
+}
+
namespace cru::ui::controls {
constexpr int k_default_caret_blink_duration = 500;
@@ -86,6 +90,9 @@ class TextHostControlService : public Object {
bool IsEditable() { return this->editable_; }
void SetEditable(bool editable);
+ bool IsContextMenuEnabled() { return this->context_menu_enabled_; }
+ void SetContextMenuEnabled(bool enabled);
+
bool IsMultiLine() { return this->multi_line_; }
// If text contains line feed characters, it will be converted to space.
void SetMultiLine(bool multi_line);
@@ -169,6 +176,15 @@ class TextHostControlService : public Object {
void SetUpShortcuts();
+ enum ContextMenuItem : unsigned {
+ kSelectAll = 0b1,
+ kCut = 0b10,
+ kCopy = 0b100,
+ kPaste = 0b1000
+ };
+
+ void OpenContextMenu(const Point& position, ContextMenuItem items);
+
private:
gsl::not_null<Control*> control_;
gsl::not_null<ITextHostControl*> text_host_control_;
@@ -182,6 +198,7 @@ class TextHostControlService : public Object {
bool enable_ = false;
bool editable_ = false;
bool multi_line_ = false;
+ bool context_menu_enabled_ = true;
bool caret_visible_ = false;
platform::gui::TimerAutoCanceler caret_timer_canceler_;
@@ -191,5 +208,8 @@ class TextHostControlService : public Object {
// true if left mouse is down and selecting
bool mouse_move_selecting_ = false;
+
+ bool context_menu_dirty_ = true;
+ std::unique_ptr<components::PopupMenu> context_menu_;
};
} // namespace cru::ui::controls