Просмотр исходного кода

Caret scrolls when out of view

Moving the caret out of view with Up/Down or Enter now scrolls to
reveal the current line
Jon Kristinsson 12 лет назад
Родитель
Сommit
5452275b01
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      Modules/Contents/UI/Source/PolyUITextInput.cpp

+ 6 - 0
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -1205,6 +1205,9 @@ void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 					updateCaretPosition();							
 				}
 			}
+            if(linesContainer->getPosition().y + (lineOffset*(lineHeight+lineSpacing)+padding) < 0.0) {
+                scrollContainer->setScrollValue(0.0, ((((lineOffset) * ((lineHeight+lineSpacing)))) + padding)/(scrollContainer->getContentSize().y-scrollContainer->getHeight()));
+            }
 		}
 		blinkerRect->visible  = true;
 		return;
@@ -1228,6 +1231,9 @@ void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 					updateCaretPosition();										
 				}
 			}
+            if(linesContainer->getPosition().y + (lineOffset*(lineHeight+lineSpacing)+padding) > scrollContainer->getHeight()-lineHeight-lineSpacing) {
+                scrollContainer->setScrollValue(0.0, (((((lineOffset) * ((lineHeight+lineSpacing)))) + padding-(scrollContainer->getHeight()-lineHeight-lineSpacing))/(scrollContainer->getContentSize().y-scrollContainer->getHeight())));
+            }
 		}
 		blinkerRect->visible  = true;		
 		return;