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

Added Home and End key support to UITextInput

Ivan Safrin 12 лет назад
Родитель
Сommit
3cf838458d
1 измененных файлов с 17 добавлено и 1 удалено
  1. 17 1
      Modules/Contents/UI/Source/PolyUITextInput.cpp

+ 17 - 1
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -1798,6 +1798,22 @@ void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 		return;
 	}
 
+	if(key == KEY_HOME) {
+		if(multiLine) {
+			scrollContainer->setScrollValue(0, 0);
+		
+		}
+		return;
+	}
+	
+	if(key == KEY_END) {
+		if(multiLine) {
+			scrollContainer->setScrollValue(0, 1);
+		
+		}
+		return;
+	}
+
 	if(key == KEY_PAGEDOWN) {
 		if(multiLine) {
 			scrollContainer->scrollVertical((scrollContainer->getHeight())/(scrollContainer->getContentSize().y));
@@ -1946,7 +1962,7 @@ void UITextInput::onKeyDown(PolyKEY key, wchar_t charCode) {
 	
 	bool _changedText = false;
 		
-	if(((charCode > 31 && charCode < 127) || charCode > 127) && key != KEY_DELETE) {
+	if(((charCode > 31 && charCode < 127) || charCode > 127) && key != KEY_DELETE && key != KEY_HOME && key != KEY_END) {
 		
 		if(!isNumberOnly || (isNumberOnly && ((charCode > 47 && charCode < 58) || (charCode == '.' || charCode == '-')))) {
 			if(!isNumberOrCharacter(charCode)) {