ManaPlus
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
TextField Class Reference

#include <textfield.h>

Inheritance diagram for TextField:
Widget FocusListener KeyListener MouseListener WidgetListener Widget2 ChatInput IntTextField PasswordField

Public Member Functions

 TextField (const Widget2 *const widget, const std::string &text, const LoseFocusOnTab loseFocusOnTab, ActionListener *const listener, const std::string &eventId, const bool sendAlwaysEvents)
 
 ~TextField ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void updateAlpha ()
 
void drawFrame (Graphics *const graphics)
 
void safeDrawFrame (Graphics *const graphics)
 
void setNumeric (const bool numeric)
 
void setRange (const int min, const int max)
 
void keyPressed (KeyEvent &event)
 
void setMinimum (const int min)
 
void setMaximum (const int max)
 
int getValue () const
 
void setSendAlwaysEvents (const bool b)
 
void adjustSize ()
 
void adjustHeight ()
 
void setCaretPosition (unsigned int position)
 
void mousePressed (MouseEvent &event)
 
void handlePaste ()
 
void handleCopy () const
 
void focusGained (const Event &event)
 
void focusLost (const Event &event)
 
void moveCaretBack ()
 
void moveCaretForward ()
 
void moveCaretWordBack ()
 
void moveCaretWordForward ()
 
void caretDelete ()
 
void caretDeleteToStart ()
 
void caretDeleteWord ()
 
void setAllowSpecialActions (const bool b)
 
std::string getTextBeforeCaret () const
 
void setText (const std::string &text)
 
const std::string & getText () const
 
unsigned int getCaretPosition () const
 
void mouseDragged (MouseEvent &event)
 
void widgetHidden (const Event &event)
 
void setParent (Widget *widget)
 
void setWindow (Widget *const widget)
 
void signalEvent ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
virtual void logic ()
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
FontgetFont () const
 
void setFont (Font *const font)
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
virtual WidgetgetWidgetAt (int x, int y)
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
- Public Member Functions inherited from FocusListener
virtual ~FocusListener ()
 
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mouseExited (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseMoved (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Protected Member Functions

void drawCaret (Graphics *graphics, int x)
 
void fixScroll ()
 
void fontChanged ()
 
bool handleNormalKeys (const InputActionT action, bool &consumed)
 
void handleCtrlKeys (const InputActionT action, bool &consumed)
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from FocusListener
 FocusListener ()
 
- Protected Member Functions inherited from KeyListener
 KeyListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 

Protected Attributes

std::string mText
 
TextChunk mTextChunk
 
unsigned int mCaretPosition
 
int mXScroll
 
const ColormCaretColor
 
int mMinimum
 
int mMaximum
 
time_t mLastEventPaste
 
int mPadding
 
bool mNumeric
 
LoseFocusOnTab mLoseFocusOnTab
 
bool mAllowSpecialActions
 
bool mSendAlwaysEvents
 
bool mTextChanged
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 

Static Protected Attributes

static SkinmSkin
 
static int instances = 0
 
static float mAlpha = 1.0
 
static ImageRect skin
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 

Detailed Description

A text field.

Definition at line 88 of file textfield.h.

Constructor & Destructor Documentation

◆ TextField()

TextField::TextField ( const Widget2 *const  widget,
const std::string &  text,
const LoseFocusOnTab  loseFocusOnTab,
ActionListener *const  listener,
const std::string &  eventId,
const bool  sendAlwaysEvents 
)

Constructor, initializes the text field with the given string.

Definition at line 109 of file textfield.cpp.

114  :
115  Widget(widget),
116  FocusListener(),
117  KeyListener(),
118  MouseListener(),
119  WidgetListener(),
120  mText(text),
121  mTextChunk(),
122  mCaretPosition(0),
123  mXScroll(0),
124  mCaretColor(&getThemeColor(ThemeColorId::CARET, 255U)),
125  mMinimum(0),
126  mMaximum(0),
127  mLastEventPaste(0),
128  mPadding(1),
129  mNumeric(false),
130  mLoseFocusOnTab(loseFocusOnTab),
131  mAllowSpecialActions(true),
132  mSendAlwaysEvents(sendAlwaysEvents),
133  mTextChanged(true)
134 {
135  mAllowLogic = false;
136  setFocusable(true);
137  addMouseListener(this);
138  addKeyListener(this);
139 
140  setFrameSize(2);
141  mForegroundColor = getThemeColor(ThemeColorId::TEXTFIELD, 255U);
142  mForegroundColor2 = getThemeColor(ThemeColorId::TEXTFIELD_OUTLINE, 255U);
143 
144  addFocusListener(this);
145 
146  if (instances == 0)
147  {
148  if (theme != nullptr)
149  {
151  "textfield.xml",
152  "textfield_background.xml",
153  0,
154  8);
155  }
156  }
157 
158  instances++;
159 
160  if (mSkin != nullptr)
161  {
163  mFrameSize = mSkin->getOption("frameSize", 2);
164  }
165 
166  adjustSize();
167  if (!eventId.empty())
168  setActionEventId(eventId);
169 
170  if (listener != nullptr)
172 }
int getOption(const std::string &name) const
Definition: skin.h:106
int getPadding() const
Definition: skin.h:100
int mMinimum
Definition: textfield.h:283
static ImageRect skin
Definition: textfield.h:282
time_t mLastEventPaste
Definition: textfield.h:285
int mPadding
Definition: textfield.h:286
bool mNumeric
Definition: textfield.h:287
const Color * mCaretColor
Definition: textfield.h:279
TextChunk mTextChunk
Definition: textfield.h:265
static Skin * mSkin
Definition: textfield.h:258
LoseFocusOnTab mLoseFocusOnTab
Definition: textfield.h:288
bool mSendAlwaysEvents
Definition: textfield.h:290
unsigned int mCaretPosition
Definition: textfield.h:270
int mXScroll
Definition: textfield.h:277
void adjustSize()
Definition: textfield.cpp:716
bool mAllowSpecialActions
Definition: textfield.h:289
bool mTextChanged
Definition: textfield.h:291
std::string mText
Definition: textfield.h:263
int mMaximum
Definition: textfield.h:284
static int instances
Definition: textfield.h:280
Skin * loadSkinRect(ImageRect &image, const std::string &name, const std::string &name2, const int start, const int end)
Definition: theme.cpp:900
Color mForegroundColor2
Definition: widget2.h:113
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
Color mForegroundColor
Definition: widget.h:1086
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:168
void setFocusable(const bool focusable)
Definition: widget.cpp:192
Widget(const Widget2 *const widget)
Definition: widget.cpp:85
unsigned int mFrameSize
Definition: widget.h:1138
bool mAllowLogic
Definition: widget.h:1160
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:272
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void addFocusListener(FocusListener *const focusListener)
Definition: widget.cpp:282
Theme * theme
Definition: theme.cpp:62

References Widget::addActionListener(), Widget::addFocusListener(), Widget::addKeyListener(), Widget::addMouseListener(), adjustSize(), Skin::getOption(), Skin::getPadding(), Widget2::getThemeColor(), instances, anonymous_namespace{itemlinkhandler.cpp}::listener, Theme::loadSkinRect(), Widget::mAllowLogic, Widget::mForegroundColor, Widget2::mForegroundColor2, Widget::mFrameSize, mPadding, mSkin, Widget::setActionEventId(), Widget::setFocusable(), Widget::setFrameSize(), skin, and theme.

◆ ~TextField()

TextField::~TextField ( )

Definition at line 174 of file textfield.cpp.

175 {
176  if (mWindow != nullptr)
178 
179  if (gui != nullptr)
180  gui->removeDragged(this);
181 
182  instances--;
183  if (instances == 0)
184  {
185  if (theme != nullptr)
186  {
187  theme->unload(mSkin);
188  Theme::unloadRect(skin, 0, 8);
189  }
190  }
192 }
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1162
void deleteImage()
Definition: textchunk.cpp:193
void unload(Skin *const skin)
Definition: theme.cpp:250
static void unloadRect(const ImageRect &rect, const int start, const int end)
Definition: theme.cpp:915
Widget * mWindow
Definition: widget2.h:112
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:307
Gui * gui
Definition: gui.cpp:111

References TextChunk::deleteImage(), gui, instances, mSkin, mTextChunk, Widget2::mWindow, Gui::removeDragged(), Widget::removeWidgetListener(), skin, theme, Theme::unload(), and Theme::unloadRect().

Member Function Documentation

◆ adjustHeight()

void TextField::adjustHeight ( )

Definition at line 724 of file textfield.cpp.

725 {
726  setHeight(getFont()->getHeight() + 2 * mPadding);
727 }
void setHeight(const int height)
Definition: widget.cpp:140
Font * getFont() const
Definition: widget.cpp:331
int getHeight() const
Definition: widget.h:240

References Widget::getFont(), Widget::getHeight(), mPadding, and Widget::setHeight().

Referenced by adjustSize().

◆ adjustSize()

void TextField::adjustSize ( )

Definition at line 716 of file textfield.cpp.

717 {
718  setWidth(getFont()->getWidth(mText) + 2 * mPadding + 1);
719  adjustHeight();
720 
721  fixScroll();
722 }
void adjustHeight()
Definition: textfield.cpp:724
void fixScroll()
Definition: textfield.cpp:729
void setWidth(const int width)
Definition: widget.cpp:133
int getWidth() const
Definition: widget.h:221

References adjustHeight(), fixScroll(), Widget::getFont(), Widget::getWidth(), mPadding, mText, and Widget::setWidth().

Referenced by LoginDialog::LoginDialog(), and TextField().

◆ caretDelete()

void TextField::caretDelete ( )

Definition at line 616 of file textfield.cpp.

617 {
618  unsigned sz = CAST_U32(mText.size());
619  while (mCaretPosition < sz)
620  {
621  --sz;
622  mText.erase(mCaretPosition, 1);
623  if (mCaretPosition == sz || (mText[mCaretPosition] & 192) != 128)
624  break;
625  }
626  mTextChanged = true;
627 }
#define CAST_U32
Definition: cast.h:31

References CAST_U32, mCaretPosition, mText, and mTextChanged.

Referenced by handleCtrlKeys().

◆ caretDeleteToStart()

void TextField::caretDeleteToStart ( )

Definition at line 641 of file textfield.cpp.

642 {
643  if (mCaretPosition > 0)
644  {
645  mText = mText.substr(mCaretPosition);
646  mCaretPosition = 0;
647  }
648  mTextChanged = true;
649 }

References mCaretPosition, mText, and mTextChanged.

Referenced by handleCtrlKeys().

◆ caretDeleteWord()

void TextField::caretDeleteWord ( )

Definition at line 690 of file textfield.cpp.

691 {
692  while (mCaretPosition > 0)
693  {
696  break;
697  }
698  mTextChanged = true;
699 }
void deleteCharLeft(std::string &str, unsigned *const pos)
bool isWordSeparator(const signed char chr) A_CONST
Definition: stringutils.h:142

References deleteCharLeft(), isWordSeparator(), mCaretPosition, mText, and mTextChanged.

Referenced by handleCtrlKeys().

◆ draw()

void TextField::draw ( Graphics *const  graphics)
virtual

Draws the text field.

Implements Widget.

Definition at line 210 of file textfield.cpp.

211 {
212  BLOCK_START("TextField::draw")
213  updateAlpha();
214 
215  Font *const font = getFont();
216  if (isFocused())
217  {
218  drawCaret(graphics,
219  font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll);
220  }
221 
222  if (mTextChanged)
223  {
224  mTextChunk.textFont = font;
229  font->generate(mTextChunk);
230  mTextChanged = false;
231  }
232 
233  const Image *const image = mTextChunk.img;
234  if (image != nullptr)
235  graphics->drawImage(image, mPadding - mXScroll, mPadding);
236 
237  BLOCK_END("TextField::draw")
238 }
Definition: font.h:90
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Font * textFont
Definition: textchunk.h:64
Image * img
Definition: textchunk.h:63
Color color
Definition: textchunk.h:66
Color color2
Definition: textchunk.h:67
std::string text
Definition: textchunk.h:65
void drawCaret(Graphics *graphics, int x)
Definition: textfield.cpp:707
void updateAlpha()
Definition: textfield.cpp:194
virtual bool isFocused() const
Definition: widget.cpp:184
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), drawCaret(), Graphics::drawImage(), Font::generate(), Widget::getFont(), Font::getWidth(), TextChunk::img, Widget::isFocused(), mCaretPosition, Widget::mForegroundColor, Widget2::mForegroundColor2, mPadding, mText, mTextChanged, mTextChunk, mXScroll, TextChunk::text, TextChunk::textFont, and updateAlpha().

Referenced by PasswordField::draw(), and safeDraw().

◆ drawCaret()

void TextField::drawCaret ( Graphics graphics,
int  x 
)
protected

Definition at line 707 of file textfield.cpp.

708 {
709  const ClipRect &clipArea = graphics->getTopClip();
710 
711  graphics->setColor(*mCaretColor);
712  graphics->drawLine(x + mPadding, clipArea.height - mPadding,
713  x + mPadding, mPadding);
714 }
virtual void setColor(const Color &color)
Definition: graphics.h:320
virtual void drawLine(int x1, int y1, int x2, int y2)=0
ClipRect & getTopClip() const
Definition: graphics.h:281
int height
Definition: rect.h:224

References Graphics::drawLine(), Graphics::getTopClip(), Rect::height, mCaretColor, mPadding, Graphics::setColor(), and x.

Referenced by draw().

◆ drawFrame()

void TextField::drawFrame ( Graphics *const  graphics)
virtual

Draws the background and border.

Reimplemented from Widget.

Definition at line 245 of file textfield.cpp.

246 {
247  BLOCK_START("TextField::drawFrame")
248  const int bs = 2 * mFrameSize;
249  graphics->drawImageRect(0,
250  0,
251  mDimension.width + bs,
252  mDimension.height + bs,
253  skin);
255 }
void drawFrame(Graphics *const graphics)
Definition: textfield.cpp:245
Rect mDimension
Definition: widget.h:1101
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final

References BLOCK_END, BLOCK_START, Graphics::drawImageRect(), Rect::height, Widget::mDimension, Widget::mFrameSize, skin, and Rect::width.

◆ fixScroll()

void TextField::fixScroll ( )
protected

Definition at line 729 of file textfield.cpp.

730 {
731  if (isFocused())
732  {
733  const int caretX = getFont()->getWidth(
734  mText.substr(0, mCaretPosition));
735 
736  const int width = mDimension.width;
737  const int pad = 2 * mPadding;
738  if (caretX - mXScroll >= width - pad)
739  {
740  mXScroll = caretX - width + pad;
741  }
742  else if (caretX - mXScroll <= 0)
743  {
744  mXScroll = caretX - width / 2;
745 
746  if (mXScroll < 0)
747  mXScroll = 0;
748  }
749  }
750 }
int getWidth(const std::string &text) const
Definition: font.cpp:334
int width
Definition: rect.h:219

References Widget::getFont(), Font::getWidth(), Widget::isFocused(), mCaretPosition, Widget::mDimension, mPadding, mText, mXScroll, and Rect::width.

Referenced by adjustSize(), fontChanged(), handleNormalKeys(), keyPressed(), mousePressed(), and setCaretPosition().

◆ focusGained()

void TextField::focusGained ( const Event event)
virtual

Called when a widget gains focus.

Parameters
eventDiscribes the event.

Reimplemented from FocusListener.

Definition at line 791 of file textfield.cpp.

792 {
793 #if defined(ANDROID) || defined(__SWITCH__)
796 #endif // ANDROID
797 }
void executeAction(const InputActionT keyNum)
InputManager inputManager
bool isKeyboardVisible()

References InputManager::executeAction(), inputManager, WindowManager::isKeyboardVisible(), and InputAction::SHOW_KEYBOARD.

◆ focusLost()

void TextField::focusLost ( const Event event)
virtual

Called when a widget loses focus.

Parameters
eventDiscribes the event.

Reimplemented from FocusListener.

Definition at line 799 of file textfield.cpp.

800 {
801 }

Referenced by ChatInput::focusLost().

◆ fontChanged()

void TextField::fontChanged ( )
protectedvirtual

Called when the font has changed. If the change is global, this function will only be called if the widget doesn't have a font already set.

Reimplemented from Widget.

Definition at line 763 of file textfield.cpp.

764 {
765  fixScroll();
766 }

References fixScroll().

◆ getCaretPosition()

unsigned int TextField::getCaretPosition ( ) const
inline

Gets the caret position. As there is only one line of text in a text field the position is the caret's x coordinate.

Returns
The caret position.
See also
setCaretPosition

Definition at line 234 of file textfield.h.

235  { return mCaretPosition; }

References mCaretPosition.

Referenced by ChatWindow::addInputText(), ChatWindow::autoComplete(), and handlePaste().

◆ getText()

const std::string& TextField::getText ( ) const
inline

◆ getTextBeforeCaret()

std::string TextField::getTextBeforeCaret ( ) const
inline

Definition at line 207 of file textfield.h.

208  { return mText.substr(0, mCaretPosition); }

References mCaretPosition, and mText.

Referenced by ChatWindow::keyPressed().

◆ getValue()

int TextField::getValue ( ) const

Return the value for a numeric field

Definition at line 286 of file textfield.cpp.

287 {
288  if (!mNumeric)
289  return 0;
290 
291  const int value = atoi(mText.c_str());
292  if (value < mMinimum)
293  return mMinimum;
294 
295  if (value > mMaximum)
296  return mMaximum;
297 
298  return value;
299 }

References mMaximum, mMinimum, mNumeric, and mText.

Referenced by Setup_Colors::Setup_Colors().

◆ handleCopy()

void TextField::handleCopy ( ) const

Definition at line 701 of file textfield.cpp.

702 {
703  std::string text = getText();
704  sendBuffer(text);
705 }
const std::string & getText() const
Definition: textfield.h:224
bool sendBuffer(const std::string &text)
Definition: copynpaste.cpp:518

References getText(), and sendBuffer().

Referenced by handleCtrlKeys(), and PopupMenu::handleLink().

◆ handleCtrlKeys()

void TextField::handleCtrlKeys ( const InputActionT  action,
bool &  consumed 
)
protected

Definition at line 496 of file textfield.cpp.

497 {
498  PRAGMA45(GCC diagnostic push)
499  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
500  switch (action)
501  {
503  {
505  consumed = true;
506  break;
507  }
509  {
511  consumed = true;
512  break;
513  }
514  case InputAction::GUI_B:
515  {
517  {
518  moveCaretBack();
519  consumed = true;
520  }
521  break;
522  }
523  case InputAction::GUI_F:
524  {
526  consumed = true;
527  break;
528  }
529  case InputAction::GUI_D:
530  {
531  caretDelete();
532  consumed = true;
533  break;
534  }
535  case InputAction::GUI_E:
536  {
537  mCaretPosition = CAST_S32(mText.size());
538  consumed = true;
539  break;
540  }
541  case InputAction::GUI_H:
542  {
544  mTextChanged = true;
545  consumed = true;
546  break;
547  }
548  case InputAction::GUI_K:
549  {
550  mText = mText.substr(0, mCaretPosition);
551  mTextChanged = true;
552  consumed = true;
553  break;
554  }
555  case InputAction::GUI_U:
556  {
558  consumed = true;
559  break;
560  }
561  case InputAction::GUI_C:
562  {
563  handleCopy();
564  consumed = true;
565  break;
566  }
567  case InputAction::GUI_V:
568  {
569 #ifdef USE_SDL2
570  handlePaste();
571 #else // USE_SDL2
572 
573  // hack to prevent paste key sticking
574  if ((mLastEventPaste != 0) && mLastEventPaste > cur_time)
575  break;
576  handlePaste();
578 #endif // USE_SDL2
579 
580  consumed = true;
581  break;
582  }
583  case InputAction::GUI_W:
584  {
585  caretDeleteWord();
586  consumed = true;
587  break;
588  }
589  default:
590  break;
591  }
592  PRAGMA45(GCC diagnostic pop)
593 }
volatile time_t cur_time
Definition: timer.cpp:58
#define CAST_S32
Definition: cast.h:30
void moveCaretForward()
Definition: textfield.cpp:605
void handleCopy() const
Definition: textfield.cpp:701
void handlePaste()
Definition: textfield.cpp:629
void caretDelete()
Definition: textfield.cpp:616
void moveCaretWordForward()
Definition: textfield.cpp:670
void caretDeleteWord()
Definition: textfield.cpp:690
void moveCaretBack()
Definition: textfield.cpp:595
void moveCaretWordBack()
Definition: textfield.cpp:651
void caretDeleteToStart()
Definition: textfield.cpp:641
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain

References caretDelete(), caretDeleteToStart(), caretDeleteWord(), CAST_S32, cur_time, deleteCharLeft(), InputAction::GUI_B, InputAction::GUI_C, InputAction::GUI_D, InputAction::GUI_E, InputAction::GUI_F, InputAction::GUI_H, InputAction::GUI_K, InputAction::GUI_LEFT, InputAction::GUI_RIGHT, InputAction::GUI_U, InputAction::GUI_V, InputAction::GUI_W, handleCopy(), handlePaste(), mAllowSpecialActions, mCaretPosition, mLastEventPaste, moveCaretBack(), moveCaretForward(), moveCaretWordBack(), moveCaretWordForward(), mText, mTextChanged, and PRAGMA45().

Referenced by keyPressed().

◆ handleNormalKeys()

bool TextField::handleNormalKeys ( const InputActionT  action,
bool &  consumed 
)
protected

Definition at line 409 of file textfield.cpp.

410 {
411  PRAGMA45(GCC diagnostic push)
412  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
413  switch (action)
414  {
416  {
417  consumed = true;
418  while (mCaretPosition > 0)
419  {
420  --mCaretPosition;
421  if ((mText[mCaretPosition] & 192) != 128)
422  break;
423  }
424  break;
425  }
426 
428  {
429  consumed = true;
430  const unsigned sz = CAST_U32(mText.size());
431  while (mCaretPosition < sz)
432  {
433  ++mCaretPosition;
434  if (mCaretPosition == sz ||
435  (mText[mCaretPosition] & 192) != 128)
436  {
437  break;
438  }
439  }
440  break;
441  }
442 
444  {
445  consumed = true;
446  unsigned sz = CAST_U32(mText.size());
447  while (mCaretPosition < sz)
448  {
449  --sz;
450  mText.erase(mCaretPosition, 1);
451  mTextChanged = true;
452  if (mCaretPosition == sz ||
453  (mText[mCaretPosition] & 192) != 128)
454  {
455  break;
456  }
457  }
458  break;
459  }
460 
462  consumed = true;
464  mTextChanged = true;
465  break;
466 
469  consumed = true;
470  fixScroll();
471  return false;
472 
474  mCaretPosition = 0;
475  consumed = true;
476  break;
477 
479  mCaretPosition = CAST_U32(mText.size());
480  consumed = true;
481  break;
482 
485  return false;
486  consumed = true;
487  break;
488 
489  default:
490  break;
491  }
492  PRAGMA45(GCC diagnostic pop)
493  return true;
494 }
void distributeActionEvent()
Definition: widget.cpp:493
const bool LoseFocusOnTab_true

References CAST_U32, deleteCharLeft(), Widget::distributeActionEvent(), fixScroll(), InputAction::GUI_BACKSPACE, InputAction::GUI_DELETE, InputAction::GUI_END, InputAction::GUI_HOME, InputAction::GUI_LEFT, InputAction::GUI_RIGHT, InputAction::GUI_SELECT2, InputAction::GUI_TAB, LoseFocusOnTab_true, mCaretPosition, mLoseFocusOnTab, mText, mTextChanged, and PRAGMA45().

Referenced by keyPressed().

◆ handlePaste()

void TextField::handlePaste ( )

Definition at line 629 of file textfield.cpp.

630 {
631  std::string text = getText();
632  size_t caretPos = CAST_SIZE(getCaretPosition());
633 
634  if (retrieveBuffer(text, caretPos))
635  {
636  setText(text);
637  setCaretPosition(CAST_U32(caretPos));
638  }
639 }
#define CAST_SIZE
Definition: cast.h:34
void setText(const std::string &text)
Definition: textfield.cpp:803
unsigned int getCaretPosition() const
Definition: textfield.h:234
void setCaretPosition(unsigned int position)
Definition: textfield.cpp:752
bool retrieveBuffer(std::string &text, size_t &pos)
Definition: copynpaste.cpp:513

References CAST_SIZE, CAST_U32, getCaretPosition(), getText(), retrieveBuffer(), setCaretPosition(), and setText().

Referenced by handleCtrlKeys(), and PopupMenu::handleLink().

◆ keyPressed()

void TextField::keyPressed ( KeyEvent event)
virtual

Processes one keypress.

Reimplemented from KeyListener.

Definition at line 301 of file textfield.cpp.

302 {
303  const int val = event.getKey().getValue();
304 
305 #ifdef USE_SDL2
306  if (val == KeyValue::TEXTINPUT)
307  {
308  std::string str = event.getText();
309  mText.insert(mCaretPosition, str);
310  mTextChanged = true;
311  mCaretPosition += CAST_U32(str.size());
312  event.consume();
313  fixScroll();
314  if (mSendAlwaysEvents)
316  return;
317  }
318  bool consumed(false);
319 #else // USE_SDL2
320 
321  if (val >= 32)
322  {
323  if (mNumeric)
324  {
325  if ((val >= '0' && val <= '9') ||
326  (val == '-' && mCaretPosition == 0U))
327  {
328  char buf[2];
329  buf[0] = CAST_8(val);
330  buf[1] = 0;
331  mText.insert(mCaretPosition, std::string(buf));
332  mTextChanged = true;
333  mCaretPosition += 1;
334  event.consume();
335  fixScroll();
336  if (mSendAlwaysEvents)
338  return;
339  }
340  }
341  else if ((mMaximum == 0) ||
342  CAST_S32(mText.size()) < mMaximum)
343  {
344  int len;
345  if (val < 128)
346  len = 1; // 0xxxxxxx
347  else if (val < 0x800)
348  len = 2; // 110xxxxx 10xxxxxx
349  else if (val < 0x10000)
350  len = 3; // 1110xxxx 10xxxxxx 10xxxxxx
351  else
352  len = 4; // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
353 
354  char buf[4];
355  for (int i = 0; i < len; ++ i)
356  {
357  buf[i] = CAST_8(val >> (6 * (len - i - 1)));
358  if (i > 0)
359  buf[i] = CAST_8((buf[i] & 63) | 128);
360  }
361 
362  if (len > 1)
363  buf[0] |= CAST_8(255U << (8 - len));
364 
365  mText.insert(mCaretPosition, std::string(buf, buf + len));
366  mCaretPosition += len;
367  mTextChanged = true;
368  event.consume();
369  fixScroll();
370  if (mSendAlwaysEvents)
372  return;
373  }
374  }
375 
376  /* In UTF-8, 10xxxxxx is only used for inner parts of characters. So skip
377  them when processing key presses. */
378 
379  // unblock past key
380  if (val != 22)
381  mLastEventPaste = 0;
382 
383  bool consumed(false);
384 #endif // USE_SDL2
385 
386  const InputActionT action = event.getActionId();
388  {
389  if (!handleNormalKeys(action, consumed))
390  {
391  if (consumed)
392  event.consume();
393  return;
394  }
395  }
396  else
397  {
398  handleCtrlKeys(action, consumed);
399  }
400 
401  if (mSendAlwaysEvents)
403 
404  if (consumed)
405  event.consume();
406  fixScroll();
407 }
#define CAST_8
Definition: cast.h:25
bool isActionActive(const InputActionT index) const
void handleCtrlKeys(const InputActionT action, bool &consumed)
Definition: textfield.cpp:496
bool handleNormalKeys(const InputActionT action, bool &consumed)
Definition: textfield.cpp:409
InputAction ::T InputActionT
Definition: inputaction.h:717
@ TEXTINPUT
Definition: keyvalue.h:128

References CAST_8, CAST_S32, CAST_U32, Widget::distributeActionEvent(), fixScroll(), InputAction::GUI_CTRL, handleCtrlKeys(), handleNormalKeys(), inputManager, InputManager::isActionActive(), mCaretPosition, mLastEventPaste, mMaximum, mNumeric, mSendAlwaysEvents, mText, mTextChanged, and KeyValue::TEXTINPUT.

Referenced by IntTextField::keyPressed().

◆ mouseDragged()

void TextField::mouseDragged ( MouseEvent event)
virtual

Called when the mouse has moved and the mouse has previously been pressed on the widget.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 812 of file textfield.cpp.

813 {
814  event.consume();
815 }

◆ mousePressed()

void TextField::mousePressed ( MouseEvent event)
virtual

Called when a mouse button has been pressed on the widget area.

NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 768 of file textfield.cpp.

769 {
770 #if defined(ANDROID) || defined(__SWITCH__)
773 #endif // ANDROID
774 
775  event.consume();
776  if (event.getButton() == MouseButton::RIGHT)
777  {
778 #ifndef DYECMD
779  if (popupMenu != nullptr)
781 #endif // DYECMD
782  }
783  else if (event.getButton() == MouseButton::LEFT)
784  {
786  mText, event.getX() + mXScroll);
787  fixScroll();
788  }
789 }
int getStringIndexAt(const std::string &text, const int x) const
Definition: font.cpp:413
MouseButtonT getButton() const
Definition: mouseevent.h:116
int getX() const
Definition: mouseevent.h:127
void showTextFieldPopup(TextField *const input)
Definition: popupmenu.cpp:2172
PopupMenu * popupMenu
Definition: popupmenu.cpp:103

References InputManager::executeAction(), fixScroll(), MouseEvent::getButton(), Widget::getFont(), Font::getStringIndexAt(), MouseEvent::getX(), inputManager, WindowManager::isKeyboardVisible(), MouseButton::LEFT, mCaretPosition, mText, mXScroll, popupMenu, MouseButton::RIGHT, InputAction::SHOW_KEYBOARD, and PopupMenu::showTextFieldPopup().

◆ moveCaretBack()

void TextField::moveCaretBack ( )

Definition at line 595 of file textfield.cpp.

596 {
597  while (mCaretPosition > 0)
598  {
599  --mCaretPosition;
600  if ((mText[mCaretPosition] & 192) != 128)
601  break;
602  }
603 }

References mCaretPosition, and mText.

Referenced by handleCtrlKeys().

◆ moveCaretForward()

void TextField::moveCaretForward ( )

Definition at line 605 of file textfield.cpp.

606 {
607  const unsigned sz = CAST_U32(mText.size());
608  while (mCaretPosition < sz)
609  {
610  ++mCaretPosition;
611  if (mCaretPosition == sz || (mText[mCaretPosition] & 192) != 128)
612  break;
613  }
614 }

References CAST_U32, mCaretPosition, and mText.

Referenced by handleCtrlKeys().

◆ moveCaretWordBack()

void TextField::moveCaretWordBack ( )

Definition at line 651 of file textfield.cpp.

652 {
653  const unsigned int oldCaret = mCaretPosition;
654  while (mCaretPosition > 0)
655  {
657  break;
658  mCaretPosition --;
659  }
660  if (oldCaret != mCaretPosition)
661  return;
662  while (mCaretPosition > 0)
663  {
665  break;
666  mCaretPosition --;
667  }
668 }

References isWordSeparator(), mCaretPosition, and mText.

Referenced by handleCtrlKeys().

◆ moveCaretWordForward()

void TextField::moveCaretWordForward ( )

Definition at line 670 of file textfield.cpp.

671 {
672  const unsigned sz = CAST_U32(mText.size());
673  const unsigned int oldCaret = mCaretPosition;
674  while (mCaretPosition < sz)
675  {
677  break;
678  mCaretPosition ++;
679  }
680  if (oldCaret != mCaretPosition)
681  return;
682  while (mCaretPosition < sz)
683  {
685  break;
686  mCaretPosition ++;
687  }
688 }

References CAST_U32, isWordSeparator(), mCaretPosition, and mText.

Referenced by handleCtrlKeys().

◆ safeDraw()

void TextField::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 240 of file textfield.cpp.

241 {
242  TextField::draw(graphics);
243 }
void draw(Graphics *const graphics)
Definition: textfield.cpp:210

References draw().

◆ safeDrawFrame()

void TextField::safeDrawFrame ( Graphics *const  graphics)
virtual

Reimplemented from Widget.

Definition at line 257 of file textfield.cpp.

258 {
259  BLOCK_START("TextField::drawFrame")
260  const int bs = 2 * mFrameSize;
261  graphics->drawImageRect(0,
262  0,
263  mDimension.width + bs,
264  mDimension.height + bs,
265  skin);
267 }

References BLOCK_END, BLOCK_START, Graphics::drawImageRect(), Rect::height, Widget::mDimension, Widget::mFrameSize, skin, and Rect::width.

◆ setAllowSpecialActions()

void TextField::setAllowSpecialActions ( const bool  b)
inline

Definition at line 204 of file textfield.h.

205  { mAllowSpecialActions = b; }

References mAllowSpecialActions.

Referenced by ChatWindow::ChatWindow().

◆ setCaretPosition()

void TextField::setCaretPosition ( unsigned int  position)

Definition at line 752 of file textfield.cpp.

753 {
754  const unsigned int sz = CAST_U32(mText.size());
755  if (position > sz)
756  mCaretPosition = CAST_S32(sz);
757  else
758  mCaretPosition = position;
759 
760  fixScroll();
761 }

References CAST_S32, CAST_U32, fixScroll(), mCaretPosition, and mText.

Referenced by ChatWindow::addInputText(), ChatWindow::autoComplete(), handlePaste(), ChatWindow::keyPressed(), RegisterDialog::postInit(), and IntTextField::setValue().

◆ setMaximum()

void TextField::setMaximum ( const int  max)
inline

Set the maximum value for a range

Definition at line 158 of file textfield.h.

159  { mMaximum = max; }

References mMaximum.

Referenced by CharCreateDialog::CharCreateDialog().

◆ setMinimum()

void TextField::setMinimum ( const int  min)
inline

Set the minimum value for a range

Definition at line 152 of file textfield.h.

153  { mMinimum = min; }

References mMinimum.

◆ setNumeric()

void TextField::setNumeric ( const bool  numeric)

Determine whether the field should be numeric or not

Definition at line 269 of file textfield.cpp.

270 {
271  mNumeric = numeric;
272  if (!numeric)
273  return;
274 
275  const char *const text = mText.c_str();
276  for (const char *textPtr = text; *textPtr != 0; ++textPtr)
277  {
278  if (*textPtr < '0' || *textPtr > '9')
279  {
280  setText(mText.substr(0, textPtr - text));
281  return;
282  }
283  }
284 }

References mNumeric, mText, and setText().

Referenced by EditServerDialog::EditServerDialog(), and Setup_Colors::Setup_Colors().

◆ setParent()

void TextField::setParent ( Widget parent)
virtual

Sets the parent of the widget. A parent must be a BasicContainer.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters
parentThe parent of the widget.
See also
getParent

Reimplemented from Widget.

Definition at line 823 of file textfield.cpp.

824 {
825  if (mWindow != nullptr)
826  mWindow->addWidgetListener(this);
827  Widget::setParent(widget);
828 }
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:302
virtual void setParent(Widget *parent)
Definition: widget.h:626

References Widget::addWidgetListener(), Widget2::mWindow, and Widget::setParent().

◆ setRange()

void TextField::setRange ( const int  min,
const int  max 
)
inline

Set the range on the field if it is numeric

Definition at line 137 of file textfield.h.

139  {
140  mMinimum = min;
141  mMaximum = max;
142  }

References mMaximum, and mMinimum.

Referenced by EditServerDialog::EditServerDialog(), Setup_Colors::Setup_Colors(), and Setup_Colors::valueChanged().

◆ setSendAlwaysEvents()

void TextField::setSendAlwaysEvents ( const bool  b)
inline

Definition at line 166 of file textfield.h.

167  { mSendAlwaysEvents = b; }

References mSendAlwaysEvents.

Referenced by BuyDialog::init().

◆ setText()

void TextField::setText ( const std::string &  text)

◆ setWindow()

void TextField::setWindow ( Widget *const  widget)
virtual

Reimplemented from Widget2.

Definition at line 830 of file textfield.cpp.

831 {
832  if ((widget == nullptr) && (mWindow != nullptr))
833  {
835  mWindow = nullptr;
836  }
837  else
838  {
839  Widget2::setWindow(widget);
840  }
841 }
virtual void setWindow(Widget *const window)
Definition: widget2.h:97

References Widget2::mWindow, Widget::removeWidgetListener(), and Widget2::setWindow().

◆ signalEvent()

void TextField::signalEvent ( )

Definition at line 843 of file textfield.cpp.

844 {
846 }

References Widget::distributeActionEvent().

Referenced by Pincode::action().

◆ updateAlpha()

void TextField::updateAlpha ( )

Update the alpha value to the graphic components.

Definition at line 194 of file textfield.cpp.

195 {
196  const float alpha = std::max(settings.guiAlpha,
198 
199  if (alpha != mAlpha)
200  {
201  mAlpha = alpha;
202  for (int a = 0; a < 9; a++)
203  {
204  if (skin.grid[a] != nullptr)
205  skin.grid[a]->setAlpha(mAlpha);
206  }
207  }
208 }
Image * grid[9]
Definition: imagerect.h:42
float guiAlpha
Definition: settings.h:131
static float mAlpha
Definition: textfield.h:281
float getMinimumOpacity() const
Definition: theme.h:124
Settings settings
Definition: settings.cpp:32

References Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, settings, skin, and theme.

Referenced by draw().

◆ widgetHidden()

void TextField::widgetHidden ( const Event event)
virtual

Invoked when a widget is hidden, i.e it's set to be not visible.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 817 of file textfield.cpp.

818 {
819  mTextChanged = true;
821 }

References TextChunk::deleteImage(), mTextChanged, and mTextChunk.

Field Documentation

◆ instances

int TextField::instances = 0
staticprotected

Definition at line 280 of file textfield.h.

Referenced by TextField(), and ~TextField().

◆ mAllowSpecialActions

bool TextField::mAllowSpecialActions
protected

Definition at line 289 of file textfield.h.

Referenced by handleCtrlKeys(), and setAllowSpecialActions().

◆ mAlpha

float TextField::mAlpha = 1.0
staticprotected

Definition at line 281 of file textfield.h.

Referenced by updateAlpha().

◆ mCaretColor

const Color* TextField::mCaretColor
protected

Definition at line 279 of file textfield.h.

Referenced by drawCaret().

◆ mCaretPosition

unsigned int TextField::mCaretPosition
protected

◆ mLastEventPaste

time_t TextField::mLastEventPaste
protected

Definition at line 285 of file textfield.h.

Referenced by handleCtrlKeys(), and keyPressed().

◆ mLoseFocusOnTab

LoseFocusOnTab TextField::mLoseFocusOnTab
protected

Definition at line 288 of file textfield.h.

Referenced by handleNormalKeys().

◆ mMaximum

int TextField::mMaximum
protected

Definition at line 284 of file textfield.h.

Referenced by getValue(), keyPressed(), setMaximum(), and setRange().

◆ mMinimum

int TextField::mMinimum
protected

Definition at line 283 of file textfield.h.

Referenced by getValue(), setMinimum(), and setRange().

◆ mNumeric

bool TextField::mNumeric
protected

Definition at line 287 of file textfield.h.

Referenced by getValue(), keyPressed(), and setNumeric().

◆ mPadding

int TextField::mPadding
protected

Definition at line 286 of file textfield.h.

Referenced by adjustHeight(), adjustSize(), draw(), drawCaret(), fixScroll(), and TextField().

◆ mSendAlwaysEvents

bool TextField::mSendAlwaysEvents
protected

Definition at line 290 of file textfield.h.

Referenced by IntTextField::keyPressed(), keyPressed(), and setSendAlwaysEvents().

◆ mSkin

Skin * TextField::mSkin
staticprotected

Definition at line 258 of file textfield.h.

Referenced by TextField(), and ~TextField().

◆ mText

std::string TextField::mText
protected

◆ mTextChanged

bool TextField::mTextChanged
protected

◆ mTextChunk

TextChunk TextField::mTextChunk
protected

Definition at line 265 of file textfield.h.

Referenced by draw(), widgetHidden(), and ~TextField().

◆ mXScroll

int TextField::mXScroll
protected

Holds the amount scrolled in x. If a user types more characters than the text field can display, due to the text field being to small, the text needs to scroll in order to show the last type character.

Definition at line 277 of file textfield.h.

Referenced by draw(), fixScroll(), and mousePressed().

◆ skin

ImageRect TextField::skin
staticprotected

Definition at line 282 of file textfield.h.

Referenced by drawFrame(), safeDrawFrame(), TextField(), updateAlpha(), and ~TextField().


The documentation for this class was generated from the following files: