aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui')
-rw-r--r--include/cru/ui/controls/TextHostControlService.hpp16
-rw-r--r--include/cru/ui/helper/ShortcutHub.hpp9
2 files changed, 13 insertions, 12 deletions
diff --git a/include/cru/ui/controls/TextHostControlService.hpp b/include/cru/ui/controls/TextHostControlService.hpp
index 0bea52c8..9e6a08bc 100644
--- a/include/cru/ui/controls/TextHostControlService.hpp
+++ b/include/cru/ui/controls/TextHostControlService.hpp
@@ -70,8 +70,10 @@ class TextHostControlService : public Object {
void SetSelection(gsl::index caret_position);
void SetSelection(TextRange selection, bool scroll_to_caret = true);
- void DeleteSelectedText();
+ void ChangeSelectionEnd(gsl::index new_end);
+ void AbortSelection();
+ void DeleteSelectedText();
// If some text is selected, then they are deleted first. Then insert text
// into caret position.
void ReplaceSelectedText(std::u16string_view text);
@@ -92,10 +94,6 @@ class TextHostControlService : public Object {
void SyncTextRenderObject();
- void StartSelection(Index start);
- void UpdateSelection(Index new_end);
- void AbortSelection();
-
void UpdateInputMethodPosition();
template <typename TArgs>
@@ -106,16 +104,14 @@ class TextHostControlService : public Object {
std::bind(handler, this, std::placeholders::_1));
}
- void SetUpHandlers();
- void TearDownHandlers();
-
void MouseMoveHandler(event::MouseEventArgs& args);
void MouseDownHandler(event::MouseButtonEventArgs& args);
void MouseUpHandler(event::MouseButtonEventArgs& args);
- void KeyDownHandler(event::KeyEventArgs& args);
void GainFocusHandler(event::FocusChangeEventArgs& args);
void LoseFocusHandler(event::FocusChangeEventArgs& args);
+ void SetUpShortcuts();
+
private:
gsl::not_null<Control*> control_;
gsl::not_null<ITextHostControl*> text_host_control_;
@@ -136,6 +132,6 @@ class TextHostControlService : public Object {
helper::ShortcutHub shortcut_hub_;
// true if left mouse is down and selecting
- bool mouse_move_selecting_;
+ bool mouse_move_selecting_ = false;
};
} // namespace cru::ui::controls
diff --git a/include/cru/ui/helper/ShortcutHub.hpp b/include/cru/ui/helper/ShortcutHub.hpp
index a4ff2da2..fe3414fe 100644
--- a/include/cru/ui/helper/ShortcutHub.hpp
+++ b/include/cru/ui/helper/ShortcutHub.hpp
@@ -19,8 +19,9 @@ namespace cru::ui::helper {
class ShortcutKeyBind {
public:
- ShortcutKeyBind(platform::gui::KeyCode key,
- platform::gui::KeyModifier modifier)
+ ShortcutKeyBind(
+ platform::gui::KeyCode key,
+ platform::gui::KeyModifier modifier = platform::gui::KeyModifiers::none)
: key_(key), modifier_(modifier) {}
CRU_DEFAULT_COPY(ShortcutKeyBind)
@@ -111,6 +112,8 @@ class ShortcutHub : public Object {
const std::vector<ShortcutInfo>& GetShortcutByKeyBind(
const ShortcutKeyBind& key_bind) const;
+ IEvent<event::KeyEventArgs&>* FallbackKeyEvent() { return &fallback_event_; }
+
void Install(controls::Control* control);
void Uninstall();
@@ -124,6 +127,8 @@ class ShortcutHub : public Object {
int current_id_ = 1;
+ Event<event::KeyEventArgs&> fallback_event_;
+
EventRevokerListGuard event_guard_;
};
} // namespace cru::ui::helper