Ver código fonte

Don't update inspectable fields while they're being edited

Marko Pintera 11 anos atrás
pai
commit
e21240a94f

+ 9 - 4
BansheeEditor/Source/BsGUIIntField.cpp

@@ -36,6 +36,7 @@ namespace BansheeEngine
 		mLayout->addElement(mInputBox);
 		mLayout->addElement(mInputBox);
 
 
 		setValue(0);
 		setValue(0);
+		mInputBox->setText(L"0");
 	}
 	}
 
 
 	GUIIntField::~GUIIntField()
 	GUIIntField::~GUIIntField()
@@ -150,10 +151,14 @@ namespace BansheeEngine
 
 
 	void GUIIntField::setValue(INT32 value)
 	void GUIIntField::setValue(INT32 value)
 	{
 	{
-		value = Math::clamp(value, mMinValue, mMaxValue);
-
-		mValue = value;
-		mInputBox->setText(toWString(value));
+		mValue = Math::clamp(value, mMinValue, mMaxValue);
+
+		// Only update with new value if it actually changed, otherwise
+		// problems can occur when user types in "0." and the field
+		// updates back to "0" effectively making "." unusable
+		float curValue = parseFloat(mInputBox->getText());
+		if (mValue != curValue)
+			mInputBox->setText(toWString(value));
 	}
 	}
 
 
 	void GUIIntField::setRange(INT32 min, INT32 max)
 	void GUIIntField::setRange(INT32 min, INT32 max)

+ 0 - 1
Inspector.txt

@@ -11,7 +11,6 @@ ARRAY TODO:
 TODO:
 TODO:
  - Ensure fields aren't updated from the app when in focus
  - Ensure fields aren't updated from the app when in focus
  - Entire foldout should be clickable, not just the toggle button
  - Entire foldout should be clickable, not just the toggle button
- - Extend text field so it can be multi-line
  - Properly hook up UndoRedo, for both in-field and object-wide changes
  - Properly hook up UndoRedo, for both in-field and object-wide changes
    - How do I track Ctrl+Z and Ctrl+Y keys? And in general how do I distinguish when I send
    - How do I track Ctrl+Z and Ctrl+Y keys? And in general how do I distinguish when I send
      input to the game and when to the editor.
      input to the game and when to the editor.

+ 5 - 2
MBansheeEditor/Inspector/InspectableFloat.cs

@@ -51,11 +51,14 @@ namespace BansheeEditor
             if (!isInitialized)
             if (!isInitialized)
                 Initialize(layoutIndex);
                 Initialize(layoutIndex);
 
 
-            // TODO - Skip update if it currently has input focus so user can modify the value in peace
-
             propertyValue = property.GetValue<float>();
             propertyValue = property.GetValue<float>();
             if (guiFloatField != null)
             if (guiFloatField != null)
+            {
+                if (guiFloatField.HasInputFocus())
+                    return;
+
                 guiFloatField.Value = propertyValue;
                 guiFloatField.Value = propertyValue;
+            }
         }
         }
 
 
         private void OnFieldValueChanged(float newValue)
         private void OnFieldValueChanged(float newValue)

+ 6 - 3
MBansheeEditor/Inspector/InspectableInt.cs

@@ -51,11 +51,14 @@ namespace BansheeEditor
             if (!isInitialized)
             if (!isInitialized)
                 Initialize(layoutIndex);
                 Initialize(layoutIndex);
 
 
-            // TODO - Skip update if it currently has input focus so user can modify the value in peace
-
             propertyValue = property.GetValue<int>();
             propertyValue = property.GetValue<int>();
-            if(guiIntField != null)
+            if (guiIntField != null)
+            {
+                if (guiIntField.HasInputFocus())
+                    return;
+
                 guiIntField.Value = propertyValue;
                 guiIntField.Value = propertyValue;
+            }
         }
         }
 
 
         private void OnFieldValueChanged(int newValue)
         private void OnFieldValueChanged(int newValue)

+ 5 - 2
MBansheeEditor/Inspector/InspectableString.cs

@@ -51,11 +51,14 @@ namespace BansheeEditor
             if (!isInitialized)
             if (!isInitialized)
                 Initialize(layoutIndex);
                 Initialize(layoutIndex);
 
 
-            // TODO - Skip update if it currently has input focus so user can modify the value in peace
-
             propertyValue = property.GetValue<string>();
             propertyValue = property.GetValue<string>();
             if (guiField != null)
             if (guiField != null)
+            {
+                if (guiField.HasInputFocus())
+                    return;
+
                 guiField.Value = propertyValue;
                 guiField.Value = propertyValue;
+            }
         }
         }
 
 
         private void OnFieldValueChanged(string newValue)
         private void OnFieldValueChanged(string newValue)

+ 5 - 2
MBansheeEditor/Inspector/InspectableVector2.cs

@@ -51,11 +51,14 @@ namespace BansheeEditor
             if (!isInitialized)
             if (!isInitialized)
                 Initialize(layoutIndex);
                 Initialize(layoutIndex);
 
 
-            // TODO - Skip update if it currently has input focus so user can modify the value in peace
-
             propertyValue = property.GetValue<Vector2>();
             propertyValue = property.GetValue<Vector2>();
             if (guiField != null)
             if (guiField != null)
+            {
+                if (guiField.HasInputFocus())
+                    return;
+
                 guiField.Value = propertyValue;
                 guiField.Value = propertyValue;
+            }
         }
         }
 
 
         private void OnFieldValueChanged(Vector2 newValue)
         private void OnFieldValueChanged(Vector2 newValue)

+ 5 - 2
MBansheeEditor/Inspector/InspectableVector3.cs

@@ -51,11 +51,14 @@ namespace BansheeEditor
             if (!isInitialized)
             if (!isInitialized)
                 Initialize(layoutIndex);
                 Initialize(layoutIndex);
 
 
-            // TODO - Skip update if it currently has input focus so user can modify the value in peace
-
             propertyValue = property.GetValue<Vector3>();
             propertyValue = property.GetValue<Vector3>();
             if (guiField != null)
             if (guiField != null)
+            {
+                if (guiField.HasInputFocus())
+                    return;
+
                 guiField.Value = propertyValue;
                 guiField.Value = propertyValue;
+            }
         }
         }
 
 
         private void OnFieldValueChanged(Vector3 newValue)
         private void OnFieldValueChanged(Vector3 newValue)

+ 5 - 2
MBansheeEditor/Inspector/InspectableVector4.cs

@@ -51,11 +51,14 @@ namespace BansheeEditor
             if (!isInitialized)
             if (!isInitialized)
                 Initialize(layoutIndex);
                 Initialize(layoutIndex);
 
 
-            // TODO - Skip update if it currently has input focus so user can modify the value in peace
-
             propertyValue = property.GetValue<Vector4>();
             propertyValue = property.GetValue<Vector4>();
             if (guiField != null)
             if (guiField != null)
+            {
+                if (guiField.HasInputFocus())
+                    return;
+
                 guiField.Value = propertyValue;
                 guiField.Value = propertyValue;
+            }
         }
         }
 
 
         private void OnFieldValueChanged(Vector4 newValue)
         private void OnFieldValueChanged(Vector4 newValue)