class ffw::GuiTextInput
Class List > ffw :: GuiTextInput
Create a user input text widget. More...
Inherits the following classes: ffw::GuiWidget
Inherited by the following classes: ffw::GuiScrollableTextInput::Inner
Classes
Type | Name |
---|---|
struct | Line |
struct | Style |
Public Functions
Type | Name |
---|---|
GuiTextInput (GuiWindow * context, bool multiline = true, bool editable = true) | |
virtual | ~GuiTextInput () = default |
void | setValue (const std::string & str) |
std::string | getValue () const |
void | appendValue (const std::string & str) |
bool | setCursorIndex (size_t strOffset, size_t lineNum) |
const std::regex & | getMatch () const |
void | setMatch (const std::regex & r) |
void | setMatch (const std::string & r) |
const std::vector< std::unique_ptr< Line > > & | getLines () const |
virtual ffw::Pointf | getMinimumWrapSize () override |
bool | isEmpty () const |
void | setStyle (const GuiTextInput::Style * style, bool defaults = false) |
const Point< size_t > & | getCursorIndex () const |
const ffw::Pointf & | getCursorPos () const |
void | insertAtCursor (const std::string & str) |
void | removeAtCursor (bool forward) |
void | moveCursor (bool forward) |
void | splitLineAtCursor () |
void | resetSelection () |
void | moveCursorToEnd () |
void | moveCursorToStart () |
void | deleteSelection () |
bool | hasSelection () const |
Detailed Description
Example code below creating a single line widget
auto gui = ffw::GuiWindowNanoVG(nvg);
auto root = gui.getLayout();
auto input = new ffw::GuiTextInput(&gui, false);
input->setSize(ffw::guiPercent(100.0f), ffw::guiPixels(25.0f));
input->setValue("Lorem Ipsum");
auto text = input->getValue(); // Returns "Lorem Ipsum"
root->addWidget(text);
// Do not free the created widgets! They will be deleted by the gui window!
while(true){
// Render the gui
}
Example code below creating a multi line widget
auto gui = ffw::GuiWindowNanoVG(nvg);
auto root = gui.getLayout();
auto input = new ffw::GuiTextInput(&gui, true);
input->setSize(ffw::guiPercent(100.0f), ffw::guiPixels(100.0f));
input->setValue("Lorem ipsum dolor sit amet\nconsectetur adipiscing elit.");
auto text = input->getValue(); // Returns the string above
root->addWidget(text);
// Do not free the created widgets! They will be deleted by the gui window!
while(true){
// Render the gui
}
Public Functions Documentation
function GuiTextInput
ffw::GuiTextInput::GuiTextInput (
GuiWindow * context,
bool multiline = true,
bool editable = true
)
function ~GuiTextInput
virtual ffw::GuiTextInput::~GuiTextInput () = default
function setValue
void ffw::GuiTextInput::setValue (
const std::string & str
)
function getValue
std::string ffw::GuiTextInput::getValue () const
function appendValue
void ffw::GuiTextInput::appendValue (
const std::string & str
)
function setCursorIndex
bool ffw::GuiTextInput::setCursorIndex (
size_t strOffset,
size_t lineNum
)
function getMatch
const std::regex & ffw::GuiTextInput::getMatch () const
function setMatch (1/2)
void ffw::GuiTextInput::setMatch (
const std::regex & r
)
function setMatch (2/2)
void ffw::GuiTextInput::setMatch (
const std::string & r
)
function getLines
const std::vector< std::unique_ptr< Line > > & ffw::GuiTextInput::getLines () const
function getMinimumWrapSize
virtual ffw::Pointf ffw::GuiTextInput::getMinimumWrapSize ()
Implements GuiWidget::getMinimumWrapSize
function isEmpty
bool ffw::GuiTextInput::isEmpty () const
function setStyle
void ffw::GuiTextInput::setStyle (
const GuiTextInput::Style * style,
bool defaults = false
)
function getCursorIndex (1/2)
const Point< size_t > & ffw::GuiTextInput::getCursorIndex () const
function getCursorPos (1/2)
const ffw::Pointf & ffw::GuiTextInput::getCursorPos () const
function insertAtCursor
void ffw::GuiTextInput::insertAtCursor (
const std::string & str
)
function removeAtCursor
void ffw::GuiTextInput::removeAtCursor (
bool forward
)
function moveCursor
void ffw::GuiTextInput::moveCursor (
bool forward
)
function splitLineAtCursor
void ffw::GuiTextInput::splitLineAtCursor ()
function resetSelection
void ffw::GuiTextInput::resetSelection ()
function moveCursorToEnd
void ffw::GuiTextInput::moveCursorToEnd ()
function moveCursorToStart
void ffw::GuiTextInput::moveCursorToStart ()
function deleteSelection
void ffw::GuiTextInput::deleteSelection ()
function hasSelection
bool ffw::GuiTextInput::hasSelection () const
The documentation for this class was generated from the following file: include/ffw/gui/guitextedit.h