|
12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #pragma once
- #include "widget/OpaqueWidget.hpp"
- #include "ui/common.hpp"
- #include "event.hpp"
- #include "app.hpp"
-
-
- namespace rack {
- namespace ui {
-
-
- struct TextField : widget::OpaqueWidget {
- std::string text;
- std::string placeholder;
- bool multiline = false;
- /** The index of the text cursor */
- int cursor = 0;
- /** The index of the other end of the selection.
- If nothing is selected, this is equal to `cursor`.
- */
- int selection = 0;
-
- TextField();
- void draw(const widget::DrawContext &ctx) override;
- void onButton(const event::Button &e) override;
- void onHover(const event::Hover &e) override;
- void onEnter(const event::Enter &e) override;
- void onSelect(const event::Select &e) override;
- void onSelectText(const event::SelectText &e) override;
- void onSelectKey(const event::SelectKey &e) override;
-
- /** Inserts text at the cursor, replacing the selection if necessary */
- void insertText(std::string text);
-
- /** Replaces the entire text */
- void setText(std::string text);
- void selectAll();
- virtual int getTextPosition(math::Vec mousePos);
- };
-
-
- } // namespace ui
- } // namespace rack
|