diff --git a/include/ui/TextField.hpp b/include/ui/TextField.hpp index bc6de559..d04ed14a 100644 --- a/include/ui/TextField.hpp +++ b/include/ui/TextField.hpp @@ -23,6 +23,7 @@ struct TextField : widget::OpaqueWidget { void draw(const DrawArgs &args) override; void onHover(const event::Hover &e) override; void onButton(const event::Button &e) override; + void onDragStart(const event::DragStart &e) override; void onEnter(const event::Enter &e) override; void onSelect(const event::Select &e) override; void onSelectText(const event::SelectText &e) override; diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp index 3656cadb..e8091408 100644 --- a/src/ui/TextField.cpp +++ b/src/ui/TextField.cpp @@ -34,6 +34,7 @@ void TextField::onHover(const event::Hover &e) { OpaqueWidget::onHover(e); if (this == APP->event->draggedWidget) { + DEBUG("asdf"); int pos = getTextPosition(e.pos); if (pos != selection) { cursor = pos; @@ -49,6 +50,11 @@ void TextField::onButton(const event::Button &e) { } } +void TextField::onDragStart(const event::DragStart &e) { + // Enable dragging so onHover can set the cursor position. + e.consume(this); +} + void TextField::onEnter(const event::Enter &e) { e.consume(this); }