mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
move window
This commit is contained in:
@@ -338,6 +338,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("setCursorEnabled", &UILineEdit::setCursorEnabled);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("setTextHidden", &UILineEdit::setTextHidden);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("setAlwaysActive", &UILineEdit::setAlwaysActive);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("setValidCharacters", &UILineEdit::setValidCharacters);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("moveCursor", &UILineEdit::moveCursor);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("appendText", &UILineEdit::appendText);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("removeCharacter", &UILineEdit::removeCharacter);
|
||||
|
@@ -276,6 +276,15 @@ void UILineEdit::appendText(std::string text)
|
||||
boost::replace_all(text, "\r", " ");
|
||||
|
||||
if(text.length() > 0) {
|
||||
|
||||
// only ignore text append if it contains invalid characters
|
||||
if(m_validCharacters.size() > 0) {
|
||||
for(uint i = 0; i < text.size(); ++i) {
|
||||
if(m_validCharacters.find(text[i]) == std::string::npos)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_text.insert(m_cursorPos, text);
|
||||
m_cursorPos += text.length();
|
||||
blinkCursor();
|
||||
@@ -291,6 +300,9 @@ void UILineEdit::appendCharacter(char c)
|
||||
return;
|
||||
|
||||
if(m_cursorPos >= 0) {
|
||||
if(m_validCharacters.size() > 0 && m_validCharacters.find(c) == std::string::npos)
|
||||
return;
|
||||
|
||||
std::string tmp;
|
||||
tmp = c;
|
||||
m_text.insert(m_cursorPos, tmp);
|
||||
|
@@ -41,6 +41,7 @@ public:
|
||||
void setCursorEnabled(bool enable);
|
||||
void setTextHidden(bool hidden);
|
||||
void setAlwaysActive(bool enable);
|
||||
void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; }
|
||||
|
||||
void moveCursor(bool right);
|
||||
void appendText(std::string text);
|
||||
@@ -76,6 +77,7 @@ private:
|
||||
int m_textHorizontalMargin;
|
||||
bool m_textHidden;
|
||||
bool m_alwaysActive;
|
||||
std::string m_validCharacters;
|
||||
|
||||
std::vector<Rect> m_glyphsCoords;
|
||||
std::vector<Rect> m_glyphsTexCoords;
|
||||
|
Reference in New Issue
Block a user