Browse Source

Allow TextField to be dragged.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
68ac69c8f1
2 changed files with 7 additions and 0 deletions
  1. +1
    -0
      include/ui/TextField.hpp
  2. +6
    -0
      src/ui/TextField.cpp

+ 1
- 0
include/ui/TextField.hpp View File

@@ -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;


+ 6
- 0
src/ui/TextField.cpp View File

@@ -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);
}


Loading…
Cancel
Save