Don't scroll Entry text if it isn't needed

This commit is contained in:
David Capello 2014-02-08 18:46:27 -03:00
parent f954556683
commit 721734d26c
2 changed files with 7 additions and 1 deletions

View File

@ -309,7 +309,7 @@ bool Entry::onProcessMessage(Message* msg)
}
// Forward scroll
else if (mousePos.x >= getBounds().x2()) {
if (m_scroll < textlen) {
if (m_scroll < textlen - getAvailableTextLength()) {
m_scroll++;
x = getBounds().x + this->border_width.l;
for (c=m_scroll; utf8_begin != utf8_end; ++c) {
@ -682,4 +682,9 @@ void Entry::backwardWord()
m_caret = 0;
}
int Entry::getAvailableTextLength()
{
return getClientChildrenBounds().w / ji_font_char_len(getFont(), 'w');
}
} // namespace ui

View File

@ -77,6 +77,7 @@ namespace ui {
void executeCmd(EntryCmd::Type cmd, int ascii, bool shift_pressed);
void forwardWord();
void backwardWord();
int getAvailableTextLength();
size_t m_maxsize;
int m_caret;