Przeglądaj źródła

Text input fields now select all on gaining focus, invisible and/or disabled UI elements will no longer focus on tab, added support for disabling focus elements when their parent prop is disabled, primitive sheet in IDE entity editor will not tab through disabled fields now

Ivan Safrin 10 lat temu
rodzic
commit
1659aa47ce

+ 4 - 2
IDE/Contents/Include/PolycodeProps.h

@@ -42,6 +42,7 @@ class PropProp : public UIElement {
 		virtual void setPropData(PolycodeEditorPropActionData* data) {}
 		
 		virtual void setPropWidth(Number width) {}
+        virtual void updateFocusVisibility() {}
         void setPropName(String newName);
     
 		String propType;
@@ -138,9 +139,10 @@ class NumberProp : public PropProp {
 		void handleEvent(Event *event);
 		void set(Number number);
 		Number get();
-		
+    
 		void setPropWidth(Number width);
-		
+        void updateFocusVisibility();
+    
 		void setPropData(PolycodeEditorPropActionData* data);
 				
 		UITextInput *numberEntry;

+ 2 - 2
IDE/Contents/Source/EditorGrid.cpp

@@ -40,7 +40,7 @@ EditorGridSettingsWindow::EditorGridSettingsWindow(EditorGrid *grid) : UIWindow(
     label->setPosition(10, 70);
     
     sizeInput = new UITextInput(false, 50, 10);
-    addChild(sizeInput);
+    addFocusChild(sizeInput);
     sizeInput->setPosition(60, 68);
     sizeInput->setNumberOnly(true);
     sizeInput->setText(String::NumberToString(grid->getGridSize()));
@@ -52,7 +52,7 @@ EditorGridSettingsWindow::EditorGridSettingsWindow(EditorGrid *grid) : UIWindow(
     label->setPosition(10, 100);
 
     countInput = new UITextInput(false, 50, 10);
-    addChild(countInput);
+    addFocusChild(countInput);
     countInput->setPosition(60, 98);
     countInput->setNumberOnly(true);
     countInput->setText(String::IntToString(grid->getGridLen()));

+ 7 - 1
IDE/Contents/Source/PolycodeProps.cpp

@@ -306,7 +306,9 @@ void PropSheet::layoutProps() {
             props[i]->setPosition(0, yOffset);
             props[i]->setPropWidth(getWidth());
             yOffset += props[i]->getHeight();
+        } else {
         }
+        props[i]->updateFocusVisibility();        
 	}
     Number newPropHeight = yOffset + contents->getPosition().y;
     if(newPropHeight != propHeight) {
@@ -892,6 +894,11 @@ void NumberProp::setPropWidth(Number width) {
 	numberEntry->setPosition(0.0, 2);
 }
 
+void NumberProp::updateFocusVisibility() {
+    numberEntry->enabled = enabled;
+    numberEntry->visible = visible;
+}
+
 void NumberProp::setPropData(PolycodeEditorPropActionData* data) {
 	set(data->numVal);
 	dispatchEvent(new Event(), Event::CHANGE_EVENT);	
@@ -2956,7 +2963,6 @@ void ScenePrimitiveSheet::updatePrimitiveLabels() {
     option5Prop->enabled = false;
     option5Prop->visible = false;
     
-
     switch(primitive->getPrimitiveType()) {
         case ScenePrimitive::TYPE_BOX:
             option1Prop->setPropName("Width");

+ 2 - 2
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -430,7 +430,7 @@ void UIElement::focusPreviousChild() {
     }
     
     for(int i=0; i < focusChildren.size(); i++) {
-        if(focusChildren[j]->isFocusable() && focusChildren[j] != UIElement::globalFocusedChild) {
+        if(focusChildren[j]->isFocusable() && focusChildren[j] != UIElement::globalFocusedChild && focusChildren[j]->enabled && focusChildren[j]->visible) {
             focusChild(focusChildren[j]);
             return;
         }
@@ -461,7 +461,7 @@ void UIElement::focusNextChild() {
     }
 
 	for(int i=0; i < focusChildren.size(); i++) {
-		if(focusChildren[j]->isFocusable() && focusChildren[j] != UIElement::globalFocusedChild) {
+		if(focusChildren[j]->isFocusable() && focusChildren[j] != UIElement::globalFocusedChild && focusChildren[j]->enabled && focusChildren[j]->visible) {
 			focusChild(focusChildren[j]);
 			return;
 		}

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

@@ -2613,6 +2613,9 @@ void UITextInput::handleEvent(Event *event) {
 void UITextInput::onGainFocus() {
     blinkerRect->visible  = true;
     blinkTimer->Reset();
+    if(!multiLine) {
+        selectAll();
+    }
 }
 
 void UITextInput::shiftText(bool left) {