Fix text edits wrapping

master
Eduardo Bart il y a 11 ans
Parent 74ebd7f903
révision cf77c2baf3

@ -26,7 +26,7 @@ end
function onGameEditText(id, itemId, maxLength, text, writter, time)
local textWindow = g_ui.createWidget('TextWindow', rootWidget)
local writeable = (maxLength ~= #text) and maxLength > 0
local writeable = #text < maxLength and maxLength > 0
local textItem = textWindow:getChildById('textItem')
local description = textWindow:getChildById('description')
local textEdit = textWindow:getChildById('text')
@ -38,7 +38,9 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
textItem:setItemId(itemId)
textEdit:setMaxLength(maxLength)
textEdit:setText(text)
textEdit:setEnabled(writeable)
textEdit:setEditable(writeable)
textEdit:setCursorVisible(writeable)
textEdit:wrapText()
local desc = ''
if #writter > 0 then
@ -63,7 +65,6 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
if not writeable then
textWindow:setText(tr('Show Text'))
textEdit:wrapText()
cancelButton:hide()
cancelButton:setWidth(0)
okButton:setMarginRight(0)
@ -105,7 +106,7 @@ function onGameEditList(id, doorId, text)
textEdit:setMaxLength(8192)
textEdit:setText(text)
textEdit:setEnabled(true)
textEdit:setEditable(true)
description:setText(tr('Enter one name per line.'))
textWindow:setText(tr('Edit List'))

@ -2,3 +2,4 @@
-- you can place any custom user code here
print 'Startup done :]'

@ -368,7 +368,7 @@ void UITextEdit::removeCharacter(bool right)
void UITextEdit::wrapText()
{
m_text = m_font->wrapText(m_text, getPaddingRect().width());
setText(m_font->wrapText(m_text, getPaddingRect().width()));
}
void UITextEdit::moveCursor(bool right)
@ -427,7 +427,8 @@ void UITextEdit::onHoverChange(bool hovered)
void UITextEdit::onTextChange(const std::string& text, const std::string& oldText)
{
m_cursorPos = text.length();
if(m_cursorPos > (int)text.length())
m_cursorPos = text.length();
blinkCursor();
update(true);
UIWidget::onTextChange(text, oldText);
@ -435,7 +436,7 @@ void UITextEdit::onTextChange(const std::string& text, const std::string& oldTex
void UITextEdit::onFontChange(const std::string& font)
{
update();
update(true);
UIWidget::onFontChange(font);
}
@ -464,7 +465,7 @@ void UITextEdit::onStyleApply(const std::string& styleName, const OTMLNodePtr& s
void UITextEdit::onGeometryChange(const Rect& oldRect, const Rect& newRect)
{
update();
update(true);
UIWidget::onGeometryChange(oldRect, newRect);
}

@ -38,7 +38,7 @@ private:
public:
void setCursorPos(int pos);
void setCursorVisible(bool enable) { m_cursorVisible = false; }
void setCursorVisible(bool enable) { m_cursorVisible = enable; }
void setTextHidden(bool hidden);
void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; }
void setShiftNavigation(bool enable) { m_shiftNavigation = enable; }

Chargement…
Annuler
Enregistrer