VCV Rack API v2
Loading...
Searching...
No Matches
TextField.hpp
Go to the documentation of this file.
1#pragma once
3#include <ui/common.hpp>
4#include <context.hpp>
5
6
7namespace rack {
8namespace ui {
9
10
12 std::string text;
13 std::string placeholder;
15 bool password = false;
16 bool multiline = false;
18 int cursor = 0;
22 int selection = 0;
23
28
30 void draw(const DrawArgs& args) override;
31 void onDragHover(const DragHoverEvent& e) override;
32 void onButton(const ButtonEvent& e) override;
33 void onSelectText(const SelectTextEvent& e) override;
34 void onSelectKey(const SelectKeyEvent& e) override;
35 virtual int getTextPosition(math::Vec mousePos);
36
37 std::string getText();
39 void setText(std::string text);
40 void selectAll();
41 std::string getSelectedText();
43 void insertText(std::string text);
50};
51
52
55 password = true;
56 }
57};
58
59
60} // namespace ui
61} // namespace rack
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
2-dimensional vector of floats, representing a point on the plane for graphics.
Definition math.hpp:189
Definition TextField.hpp:53
PasswordField()
Definition TextField.hpp:54
Definition TextField.hpp:11
bool multiline
Definition TextField.hpp:16
Widget * nextField
Definition TextField.hpp:27
int selection
The index of the other end of the selection.
Definition TextField.hpp:22
void onButton(const ButtonEvent &e) override
std::string getSelectedText()
void draw(const DrawArgs &args) override
Draws the widget to the NanoVG context.
std::string placeholder
Definition TextField.hpp:13
std::string text
Definition TextField.hpp:12
void onSelectText(const SelectTextEvent &e) override
void onSelectKey(const SelectKeyEvent &e) override
bool password
Masks text with "*".
Definition TextField.hpp:15
void insertText(std::string text)
Inserts text at the cursor, replacing the selection if necessary.
void setText(std::string text)
Replaces the entire text.
std::string getText()
Widget * prevField
For Tab and Shift-Tab focusing.
Definition TextField.hpp:26
void onDragHover(const DragHoverEvent &e) override
virtual int getTextPosition(math::Vec mousePos)
int cursor
The index of the text cursor.
Definition TextField.hpp:18
A Widget that stops propagation of all recursive PositionEvents (such as ButtonEvent) but gives a cha...
Definition OpaqueWidget.hpp:12
Occurs each mouse button press or release.
Definition Widget.hpp:237
Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same o...
Definition Widget.hpp:391
Definition Widget.hpp:141
Occurs when a key is pressed, released, or repeated while a Widget is selected.
Definition Widget.hpp:352
Occurs when text is typed while a Widget is selected.
Definition Widget.hpp:358
A node in the 2D scene graph.
Definition Widget.hpp:21