SimpleInput class reference
Basic interactive widget - displays a input control that reacts to mouse clicks and keyboard inputs. It supports
keyboard shortcuts like: Ctrl+A, Ctrl+X, Ctrl+C, Ctrl+V, Left and right Arrows, Backspace.
SimpleInput input(window, {{0,0}, {100, 30}}, theme);
Functions
Functions documentation
SimpleInput(Window* window, constWidget2DProps& props =Widget2DProps({ 0,0 }, { 0,0 },Anchor::Left |Anchor::Bottom |ResizePolicy::AutoFill), constSimpleInputTheme& rectProps =SimpleInputTheme(), std::wstring defaultText = L"" );
Default constructor.
SimpleInput(Window* window, constWidget2DProps& props =Widget2DProps({ 0,0 }, { 0,0 },Anchor::Left |Anchor::Bottom |ResizePolicy::AutoFill), constTheme& theme =Theme(), std::wstring defaultText = L"" );
Delegating constructor with theme application.
SimpleInput(constSimpleInput& copy);
Copy constructor.
virtual ~SimpleInput();
Destructor.
SimpleInput& operator=(SimpleInputrhs);
Assignment operator.
friend void swap(SimpleInput& first,SimpleInput& second) noexcept;
Swap function.
SimpleInput* Clone() const override;
Clones the object (usefull while making copy of object that is casted to its base).
const std::wstring& GetTextRef() const;Returns reference to the input text (quick access).
std::wstring GetTextWhenEnter();Returns the current input text (useful when using the pooling technique). When Enter key was not pressed returns empty std::wstirng -> L"".
void SetCallback(Callback function);Sets a callback that is executed every time an event is processed (inside SimpleInput object).
void ResetCallback();Resets the callback to nullptr.
void SetFilter(std::function<bool(KbCharAppearEvent*)> function);
Sets the filter that passes specific characters to the SimpleInput widget. There are 5 predefinied filters: IntNumericFilter, FloatNumericFilter, AlphabeticFilter, AlphaNumericFilter, CustomFilter.
void ResetFilter();Resets the filter to nullptr.
WidgetMouseStateGetState();
Returns the current status of the widget (useful when using the pooling technique).
void SetColor(WidgetMouseStateforState,Colorcolor);
Sets the background color for a given widget state.
Sets the background color for all widget states.
void SetBorderColor(WidgetMouseStateforState,Colorcolor);
Sets the border color for a given widget state.
Sets the border color for all widget states.
void SetBoderSize(Dimension<int> newBorderSize);
Sets the widget border size.
void SetFontSize(int newSize);Sets the font size for the text inside Input field.
void SetText(std::wstring newText);Sets the text inside Input field.
void SetFont(Font* newFont);
Sets the new font for the input text. (Requires redrawn to show changes)
void SetFontColor(ColornewColor);
Sets the font color for all widget states.
void SetFlags(int newFlags) override;Sets the widget flags.
void SetTextMargin(Point<int> newMargins);Sets the text margins to the left bottom position of the widget.
void SetDefaultTextColor(ColornewColor);
Sets new font color for the default text.
void SetDefaultText(std::wstring newDefaultText);Dets new default text.
void UnregisterEvent(EventTypeeventType) override;
Allows to unregister the widget from a specific event in the parent window.
ColorGetColor(WidgetMouseStateforState) const;
Returns the background color for a given widget state.
ColorGetBorderColor(WidgetMouseStateforState) const;
Returns the border color for a given widget state.
constDimension<int>& GetBoderSize() const;
Returns the border size of the widget.
int GetFontSize() const;Returns font size used by widget to render text.
std::wstring GetText() const;Returns the input text.
ColorGetFontColor() const;
Returns font color used by widget to render text.
Font* GetUsedFont() const;
Returns pointer to the font object used by widget to render text.
const Point<int>& GetTextMargin() const;Returns the text margins to the left bottom position of the widget.
ColorGetDefaultTextColor() const;
Returns the default text color.
std::wstring GetDefaultText() const;Returns the default text.
void CalcAnchorOffsets();Converts the location of the widget depending on the flags set (Anchor).
void UpdateSelection();Helper function. Updates the rectangular area which marks the text while selecting it via mouse.
Variables documentation
bool m_Enter;Stores information whether the enter key has been pressed.
int m_iTicks;Internal widget counter.
int m_iPromptIdx;Describes current prompt position.
float m_fPromptPos;Describes current prompt position in 2D space (X offset)
bool m_bActive;Describes whether the SimpleInput widget is active or not.
bool m_bDrag;Stores information whether the user drags the mouse over the button.
int m_iDragStart, m_iDragEnd;Stores start and end position of the cursor (in characters) while user is dragging mouse.
Point<int> m_AnchorOffsets;Stores precalculated (depending on Anchor flags) offsets.
WidgetMouseStatem_State;
Stores widet state. (depends on mouse actions and m_bActive variable)
Background* m_Background;
Represents the background of the SimpleInput widget.
Rectangle2D* m_BottomBar;Graphical indicator of SimpleInput widget. (bottom bar)
Rectangle2D* m_Prompt;Represents the prompt/cursor in the input field.
Rectangle2D* m_Selection;Represents the text selection.
Text* m_Text;
Represents the text in the input field.
Text* m_DefaultText;
Represents the default text in the input field.
SimpleInputThemem_InpTheme;
Stores widget theme.
Callback m_Callback;Stores callback function.
std::function<bool(KbCharAppearEvent*)> m_FilterFunc;
Stores filter function.