mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 20:36:53 +01:00
EditorPropertyArray Fix crash when drag-reordering elements in the inspector
(cherry picked from commit 33b29704926f623f97402e0cfbf2591a163b8ab6)
This commit is contained in:
parent
8f1ac63f60
commit
3f7569cb91
@ -647,11 +647,16 @@ void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_eve
|
||||
Variant array = object->get_array();
|
||||
int size = array.call("size");
|
||||
|
||||
if ((reorder_to_index == 0 && mm->get_relative().y < 0.0f) || (reorder_to_index == size - 1 && mm->get_relative().y > 0.0f)) {
|
||||
// Cumulate the mouse delta, many small changes (dragging slowly) should result in reordering at some point.
|
||||
reorder_mouse_y_delta += mm->get_relative().y;
|
||||
|
||||
// Reordering is done by moving the dragged element by +1/-1 index at a time based on the cumulated mouse delta so if
|
||||
// already at the array bounds make sure to ignore the remaining out of bounds drag (by resetting the cumulated delta).
|
||||
if ((reorder_to_index == 0 && reorder_mouse_y_delta < 0.0f) || (reorder_to_index == size - 1 && reorder_mouse_y_delta > 0.0f)) {
|
||||
reorder_mouse_y_delta = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
reorder_mouse_y_delta += mm->get_relative().y;
|
||||
float required_y_distance = 20.0f * EDSCALE;
|
||||
if (ABS(reorder_mouse_y_delta) > required_y_distance) {
|
||||
int direction = reorder_mouse_y_delta > 0.0f ? 1 : -1;
|
||||
|
Loading…
Reference in New Issue
Block a user