mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 20:14:54 +02:00
spinbox improvements
This commit is contained in:
@@ -285,11 +285,12 @@ void UILineEdit::appendText(std::string text)
|
||||
}
|
||||
}
|
||||
|
||||
std::string oldText = m_text;
|
||||
m_text.insert(m_cursorPos, text);
|
||||
m_cursorPos += text.length();
|
||||
blinkCursor();
|
||||
update();
|
||||
UIWidget::onTextChange(m_text);
|
||||
UIWidget::onTextChange(m_text, oldText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,16 +306,18 @@ void UILineEdit::appendCharacter(char c)
|
||||
|
||||
std::string tmp;
|
||||
tmp = c;
|
||||
std::string oldText = m_text;
|
||||
m_text.insert(m_cursorPos, tmp);
|
||||
m_cursorPos++;
|
||||
blinkCursor();
|
||||
update();
|
||||
UIWidget::onTextChange(m_text);
|
||||
UIWidget::onTextChange(m_text, oldText);
|
||||
}
|
||||
}
|
||||
|
||||
void UILineEdit::removeCharacter(bool right)
|
||||
{
|
||||
std::string oldText = m_text;
|
||||
if(m_cursorPos >= 0 && m_text.length() > 0) {
|
||||
if((uint)m_cursorPos >= m_text.length()) {
|
||||
m_text.erase(m_text.begin() + (--m_cursorPos));
|
||||
@@ -326,7 +329,7 @@ void UILineEdit::removeCharacter(bool right)
|
||||
}
|
||||
blinkCursor();
|
||||
update();
|
||||
UIWidget::onTextChange(m_text);
|
||||
UIWidget::onTextChange(m_text, oldText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,12 +379,12 @@ std::string UILineEdit::getDisplayedText()
|
||||
return m_text;
|
||||
}
|
||||
|
||||
void UILineEdit::onTextChange(const std::string& text)
|
||||
void UILineEdit::onTextChange(const std::string& text, const std::string& oldText)
|
||||
{
|
||||
m_cursorPos = text.length();
|
||||
blinkCursor();
|
||||
update();
|
||||
UIWidget::onTextChange(text);
|
||||
UIWidget::onTextChange(text, oldText);
|
||||
}
|
||||
|
||||
void UILineEdit::onFontChange(const std::string& font)
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
bool isTextHidden() { return m_textHidden; }
|
||||
|
||||
protected:
|
||||
virtual void onTextChange(const std::string& text);
|
||||
virtual void onTextChange(const std::string& text, const std::string& oldText);
|
||||
virtual void onFontChange(const std::string& font);
|
||||
virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
|
||||
virtual void onGeometryChange(const Rect& oldRect, const Rect& newRect);
|
||||
|
@@ -426,7 +426,7 @@ private:
|
||||
protected:
|
||||
void drawText(const Rect& screenCoords);
|
||||
|
||||
virtual void onTextChange(const std::string& text);
|
||||
virtual void onTextChange(const std::string& text, const std::string& oldText);
|
||||
virtual void onFontChange(const std::string& font);
|
||||
|
||||
std::string m_text;
|
||||
|
@@ -74,9 +74,9 @@ void UIWidget::drawText(const Rect& screenCoords)
|
||||
m_textFramebuffer->draw(screenCoords);
|
||||
}
|
||||
|
||||
void UIWidget::onTextChange(const std::string& text)
|
||||
void UIWidget::onTextChange(const std::string& text, const std::string& oldText)
|
||||
{
|
||||
callLuaField("onTextChange", text);
|
||||
callLuaField("onTextChange", text, oldText);
|
||||
}
|
||||
|
||||
void UIWidget::onFontChange(const std::string& font)
|
||||
@@ -94,6 +94,7 @@ void UIWidget::setText(const std::string& text)
|
||||
if(m_text == text)
|
||||
return;
|
||||
|
||||
std::string oldText = m_text;
|
||||
m_text = text;
|
||||
|
||||
// update rect size
|
||||
@@ -107,7 +108,7 @@ void UIWidget::setText(const std::string& text)
|
||||
setSize(newSize);
|
||||
}
|
||||
|
||||
onTextChange(text);
|
||||
onTextChange(text, oldText);
|
||||
m_textMustRecache = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user