Allow text box widget to process left / right events

This commit is contained in:
Benau 2018-11-16 19:46:48 +08:00
parent 264b79ef0d
commit eb8b68dcb6
3 changed files with 24 additions and 1 deletions

View File

@ -120,7 +120,8 @@ using namespace gui;
virtual void setDrawBackground(bool) { }
void openScreenKeyboard();
s32 getCursorPosInBox() const { return CursorPos; }
s32 getTextCount() const { return (s32)Text.size(); }
protected:
//! Breaks the single text line.
void breakText();

View File

@ -209,3 +209,22 @@ EventPropagation TextBoxWidget::onActivationInput(const int playerID)
// event to avoid breaking something
return EVENT_BLOCK;
}
// -----------------------------------------------------------------------------
EventPropagation TextBoxWidget::rightPressed(const int playerID)
{
if (((MyCGUIEditBox*)m_element)->getTextCount() ==
((MyCGUIEditBox*)m_element)->getCursorPosInBox())
return EVENT_BLOCK;
return EVENT_LET;
} // rightPressed
// -----------------------------------------------------------------------------
EventPropagation TextBoxWidget::leftPressed (const int playerID)
{
if (((MyCGUIEditBox*)m_element)->getCursorPosInBox() == 0)
return EVENT_BLOCK;
return EVENT_LET;
} // leftPressed

View File

@ -77,6 +77,9 @@ namespace GUIEngine
virtual void setActive(bool active=true);
virtual EventPropagation onActivationInput(const int playerID);
virtual EventPropagation rightPressed(const int playerID);
virtual EventPropagation leftPressed (const int playerID);
};
}