Class TextBox¶
Defined in File textbox.h
Page Contents
Inheritance Relationships¶
Base Type¶
public nanogui::Widget
(Class Widget)
Derived Types¶
public nanogui::FloatBox< T >
(Template Class FloatBox)public nanogui::IntBox< T >
(Template Class IntBox)public nanogui::detail::FormWidget< std::string, std::true_type >
(Template Class FormWidget< std::string, std::true_type >)public nanogui::FloatBox< Scalar >
(Template Class FloatBox)public nanogui::IntBox< Scalar >
(Template Class IntBox)
Class Documentation¶
-
class
TextBox
: public nanogui::Widget¶ Fancy text box with builtin regular expression-based validation.
- Remark
This class overrides nanogui::Widget::mIconExtraScale to be
0.8f
, which affects all subclasses of this Widget. Subclasses must explicitly set a different value if needed (e.g., in their constructor).
Subclassed by nanogui::FloatBox< T >, nanogui::IntBox< T >, nanogui::detail::FormWidget< std::string, std::true_type >, nanogui::FloatBox< Scalar >, nanogui::IntBox< Scalar >
Public Functions
-
bool
editable
() const¶
-
void
setEditable
(bool editable)¶
-
bool
spinnable
() const¶
-
void
setSpinnable
(bool spinnable)¶
-
const std::string &
value
() const¶
-
void
setValue
(const std::string &value)¶
-
const std::string &
defaultValue
() const¶
-
void
setDefaultValue
(const std::string &defaultValue)¶
-
const std::string &
units
() const¶
-
void
setUnits
(const std::string &units)¶
-
int
unitsImage
() const¶
-
void
setUnitsImage
(int image)¶
-
const std::string &
format
() const¶ Return the underlying regular expression specifying valid formats.
-
void
setFormat
(const std::string &format)¶ Specify a regular expression specifying valid formats.
-
const std::string &
placeholder
() const¶ Return the placeholder text to be displayed while the text box is empty.
-
void
setPlaceholder
(const std::string &placeholder)¶ Specify a placeholder text to be displayed while the text box is empty.
-
std::function<bool(const std::string &str)>
callback
() const¶ The callback to execute when the value of this TextBox has changed.
-
void
setCallback
(const std::function<bool(const std::string &str)> &callback)¶ Sets the callback to execute when the value of this TextBox has changed.
-
virtual bool
mouseButtonEvent
(const Vector2i &p, int button, bool down, int modifiers)¶ Handle a mouse button event (default implementation: propagate to children)
-
virtual bool
mouseMotionEvent
(const Vector2i &p, const Vector2i &rel, int button, int modifiers)¶ Handle a mouse motion event (default implementation: propagate to children)
-
virtual bool
mouseDragEvent
(const Vector2i &p, const Vector2i &rel, int button, int modifiers)¶ Handle a mouse drag event (default implementation: do nothing)
-
virtual bool
focusEvent
(bool focused)¶ Handle a focus change event (default implementation: record the focus status, but do nothing)
-
virtual bool
keyboardEvent
(int key, int scancode, int action, int modifiers)¶ Handle a keyboard event (default implementation: do nothing)
-
virtual bool
keyboardCharacterEvent
(unsigned int codepoint)¶ Handle text input (UTF-32 format) (default implementation: do nothing)
-
virtual void
draw
(NVGcontext *ctx)¶ Draw the widget (and all child widgets)
-
virtual void
save
(Serializer &s) const¶ Save the state of the widget into the given Serializer instance.
-
virtual bool
load
(Serializer &s)¶ Restore the state of the widget from the given Serializer instance.
Protected Functions
-
bool
checkFormat
(const std::string &input, const std::string &format)¶
-
bool
copySelection
()¶
-
void
pasteFromClipboard
()¶
-
bool
deleteSelection
()¶
-
void
updateCursor
(NVGcontext *ctx, float lastx, const NVGglyphPosition *glyphs, int size)¶
-
float
cursorIndex2Position
(int index, float lastx, const NVGglyphPosition *glyphs, int size)¶
-
int
position2CursorIndex
(float posx, float lastx, const NVGglyphPosition *glyphs, int size)¶
Protected Attributes
-
bool
mEditable
¶
-
bool
mSpinnable
¶
-
bool
mCommitted
¶
-
std::string
mValue
¶
-
std::string
mDefaultValue
¶
-
std::string
mUnits
¶
-
std::string
mFormat
¶
-
int
mUnitsImage
¶
-
std::function<bool(const std::string &str)>
mCallback
¶
-
bool
mValidFormat
¶
-
std::string
mValueTemp
¶
-
std::string
mPlaceholder
¶
-
int
mCursorPos
¶
-
int
mSelectionPos
¶
-
int
mMouseDownModifier
¶
-
float
mTextOffset
¶
-
double
mLastClick
¶