Fix text edits wrapping
This commit is contained in:
parent
74ebd7f903
commit
cf77c2baf3
|
@ -26,7 +26,7 @@ end
|
||||||
function onGameEditText(id, itemId, maxLength, text, writter, time)
|
function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||||
local textWindow = g_ui.createWidget('TextWindow', rootWidget)
|
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 textItem = textWindow:getChildById('textItem')
|
||||||
local description = textWindow:getChildById('description')
|
local description = textWindow:getChildById('description')
|
||||||
local textEdit = textWindow:getChildById('text')
|
local textEdit = textWindow:getChildById('text')
|
||||||
|
@ -38,7 +38,9 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||||
textItem:setItemId(itemId)
|
textItem:setItemId(itemId)
|
||||||
textEdit:setMaxLength(maxLength)
|
textEdit:setMaxLength(maxLength)
|
||||||
textEdit:setText(text)
|
textEdit:setText(text)
|
||||||
textEdit:setEnabled(writeable)
|
textEdit:setEditable(writeable)
|
||||||
|
textEdit:setCursorVisible(writeable)
|
||||||
|
textEdit:wrapText()
|
||||||
|
|
||||||
local desc = ''
|
local desc = ''
|
||||||
if #writter > 0 then
|
if #writter > 0 then
|
||||||
|
@ -63,7 +65,6 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||||
|
|
||||||
if not writeable then
|
if not writeable then
|
||||||
textWindow:setText(tr('Show Text'))
|
textWindow:setText(tr('Show Text'))
|
||||||
textEdit:wrapText()
|
|
||||||
cancelButton:hide()
|
cancelButton:hide()
|
||||||
cancelButton:setWidth(0)
|
cancelButton:setWidth(0)
|
||||||
okButton:setMarginRight(0)
|
okButton:setMarginRight(0)
|
||||||
|
@ -105,7 +106,7 @@ function onGameEditList(id, doorId, text)
|
||||||
|
|
||||||
textEdit:setMaxLength(8192)
|
textEdit:setMaxLength(8192)
|
||||||
textEdit:setText(text)
|
textEdit:setText(text)
|
||||||
textEdit:setEnabled(true)
|
textEdit:setEditable(true)
|
||||||
description:setText(tr('Enter one name per line.'))
|
description:setText(tr('Enter one name per line.'))
|
||||||
textWindow:setText(tr('Edit List'))
|
textWindow:setText(tr('Edit List'))
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
-- you can place any custom user code here
|
-- you can place any custom user code here
|
||||||
|
|
||||||
print 'Startup done :]'
|
print 'Startup done :]'
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ void UITextEdit::removeCharacter(bool right)
|
||||||
|
|
||||||
void UITextEdit::wrapText()
|
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)
|
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)
|
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();
|
blinkCursor();
|
||||||
update(true);
|
update(true);
|
||||||
UIWidget::onTextChange(text, oldText);
|
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)
|
void UITextEdit::onFontChange(const std::string& font)
|
||||||
{
|
{
|
||||||
update();
|
update(true);
|
||||||
UIWidget::onFontChange(font);
|
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)
|
void UITextEdit::onGeometryChange(const Rect& oldRect, const Rect& newRect)
|
||||||
{
|
{
|
||||||
update();
|
update(true);
|
||||||
UIWidget::onGeometryChange(oldRect, newRect);
|
UIWidget::onGeometryChange(oldRect, newRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setCursorPos(int pos);
|
void setCursorPos(int pos);
|
||||||
void setCursorVisible(bool enable) { m_cursorVisible = false; }
|
void setCursorVisible(bool enable) { m_cursorVisible = enable; }
|
||||||
void setTextHidden(bool hidden);
|
void setTextHidden(bool hidden);
|
||||||
void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; }
|
void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; }
|
||||||
void setShiftNavigation(bool enable) { m_shiftNavigation = enable; }
|
void setShiftNavigation(bool enable) { m_shiftNavigation = enable; }
|
||||||
|
|
Loading…
Reference in New Issue