|
|
@@ -844,6 +844,7 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
|
|
|
inEditAttribute = true;
|
|
|
|
|
|
Array<Variant> oldValues;
|
|
|
+
|
|
|
if (!dragEditAttribute)
|
|
|
{
|
|
|
// Store old values so that PostEditAttribute can create undo actions
|
|
|
@@ -854,15 +855,14 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
|
|
|
StoreAttributeEditor(parent, serializables, index, subIndex, coordinate);
|
|
|
for (uint i = 0; i < serializables.length; ++i)
|
|
|
serializables[i].ApplyAttributes();
|
|
|
-
|
|
|
- //disable undo
|
|
|
+
|
|
|
if (!dragEditAttribute)
|
|
|
{
|
|
|
// Do the editor post logic after attribute has been modified.
|
|
|
PostEditAttribute(serializables, index, oldValues);
|
|
|
}
|
|
|
|
|
|
- // Update the stored script attributes if this is a ScriptInstance
|
|
|
+ // Update the stored script attributes if this is a ScriptInstance
|
|
|
EditScriptAttributes(serializables[0], index);
|
|
|
|
|
|
inEditAttribute = false;
|
|
|
@@ -878,15 +878,15 @@ void LineDragBegin(StringHash eventType, VariantMap& eventData)
|
|
|
UIElement@ label = eventData["Element"].GetPtr();
|
|
|
int x = eventData["X"].GetInt();
|
|
|
label.vars["posX"] = x;
|
|
|
-
|
|
|
- //store value old value before dragging
|
|
|
+
|
|
|
+ // Store the old value before dragging
|
|
|
dragEditAttribute = false;
|
|
|
LineEdit@ selectedNumEditor = label.parent;
|
|
|
- //not convenient way to trigger EditAttribute event
|
|
|
- selectedNumEditor.text = selectedNumEditor.text;
|
|
|
+
|
|
|
selectedNumEditor.vars["DragBeginValue"] = selectedNumEditor.text;
|
|
|
selectedNumEditor.cursorPosition = 0;
|
|
|
|
|
|
+ // Set mouse mode to user preference
|
|
|
SetMouseMode(true);
|
|
|
}
|
|
|
|
|
|
@@ -895,6 +895,9 @@ void LineDragMove(StringHash eventTypem, VariantMap& eventData)
|
|
|
UIElement@ label = eventData["Element"].GetPtr();
|
|
|
LineEdit@ selectedNumEditor = label.parent;
|
|
|
|
|
|
+ // Prevent undo
|
|
|
+ dragEditAttribute = true;
|
|
|
+
|
|
|
int x = eventData["X"].GetInt();
|
|
|
int posx = label.vars["posX"].GetInt();
|
|
|
float val = input.mouseMoveX;
|
|
|
@@ -904,13 +907,28 @@ void LineDragMove(StringHash eventTypem, VariantMap& eventData)
|
|
|
label.vars["posX"] = x;
|
|
|
selectedNumEditor.text = fieldVal;
|
|
|
selectedNumEditor.cursorPosition = 0;
|
|
|
- //disable storing undo
|
|
|
- dragEditAttribute = true;
|
|
|
}
|
|
|
|
|
|
void LineDragEnd(StringHash eventType, VariantMap& eventData)
|
|
|
{
|
|
|
+ UIElement@ label = eventData["Element"].GetPtr();
|
|
|
+ LineEdit@ selectedNumEditor = label.parent;
|
|
|
+
|
|
|
+ // Prepare the attributes to store an undo with:
|
|
|
+ // - old value = drag begin value
|
|
|
+ // - new value = final value
|
|
|
+
|
|
|
+ String finalValue = selectedNumEditor.text;
|
|
|
+ // Reset attribute to begin value, and prevent undo
|
|
|
+ dragEditAttribute = true;
|
|
|
+ selectedNumEditor.text = selectedNumEditor.vars["DragBeginValue"].GetString();
|
|
|
+
|
|
|
+ // Store final value, allow undo
|
|
|
dragEditAttribute = false;
|
|
|
+ selectedNumEditor.text = finalValue;
|
|
|
+ selectedNumEditor.cursorPosition = 0;
|
|
|
+
|
|
|
+ // Revert mouse to normal behaviour
|
|
|
SetMouseMode(false);
|
|
|
}
|
|
|
|
|
|
@@ -918,11 +936,13 @@ void LineDragCancel(StringHash eventType, VariantMap& eventData)
|
|
|
{
|
|
|
UIElement@ label = eventData["Element"].GetPtr();
|
|
|
|
|
|
- //prevent undo triggering
|
|
|
+ // Reset value to what it was when drag edit began, preventing undo.
|
|
|
dragEditAttribute = true;
|
|
|
LineEdit@ selectedNumEditor = label.parent;
|
|
|
selectedNumEditor.text = selectedNumEditor.vars["DragBeginValue"].GetString();
|
|
|
selectedNumEditor.cursorPosition = 0;
|
|
|
+
|
|
|
+ // Revert mouse to normal behaviour
|
|
|
SetMouseMode(false);
|
|
|
}
|
|
|
|