diff options
Diffstat (limited to 'CruUI/ui/controls/text_block.cpp')
-rw-r--r-- | CruUI/ui/controls/text_block.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/CruUI/ui/controls/text_block.cpp b/CruUI/ui/controls/text_block.cpp index 00850b0b..3d53da7c 100644 --- a/CruUI/ui/controls/text_block.cpp +++ b/CruUI/ui/controls/text_block.cpp @@ -25,11 +25,7 @@ namespace cru } TextBlock::TextBlock(const Microsoft::WRL::ComPtr<IDWriteTextFormat>& init_text_format, - const Microsoft::WRL::ComPtr<ID2D1Brush>& init_brush) : Control(false), - window_deactivated_handler_(new events::UiEvent::EventHandler([this](events::UiEvent::ArgsType& args) - { - is_selecting_ = false; - })) + const Microsoft::WRL::ComPtr<ID2D1Brush>& init_brush) : Control(false) { text_format_ = init_text_format; if (init_brush == nullptr) @@ -63,18 +59,6 @@ namespace cru Repaint(); } - void TextBlock::OnAttachToWindow(Window* window) - { - Control::OnAttachToWindow(window); - window->deactivated_event.AddHandler(window_deactivated_handler_); - } - - void TextBlock::OnDetachToWindow(Window* window) - { - Control::OnDetachToWindow(window); - window->deactivated_event.RemoveHandler(window_deactivated_handler_); - } - void TextBlock::OnSizeChangedCore(events::SizeChangedEventArgs& args) { text_layout_->SetMaxWidth(args.GetNewSize().width); @@ -171,10 +155,18 @@ namespace cru Control::OnMouseUpCore(args); } - void TextBlock::OnLoseFocusCore(events::UiEventArgs& args) + void TextBlock::OnLoseFocusCore(events::FocusChangeEventArgs& args) { - selected_range_ = std::nullopt; - Repaint(); + if (is_selecting_) + { + is_selecting_ = false; + GetWindow()->ReleaseCurrentMouseCapture(); + } + if (!args.IsWindow()) + { + selected_range_ = std::nullopt; + Repaint(); + } Control::OnLoseFocusCore(args); } |