Fix T87637: Dragging button value cancel not working

Dragging a number button, then holding the value and pressing escape
would not reset the value correctly.
This was because eb06ccc324 assumed that `data->value` and
`data->startvalue` were set during dragging which they are not.

The fix moves the if statement into the section where we check if a
number was entered (number edit) making sure that we only cancel
if the button was in "string enter" mode and that the value entered
was the same as before.

Reviewed By: HooglyBoogly, Severin

Maniphest Tasks: T87637

Differential Revision: https://developer.blender.org/D11021
This commit is contained in:
Falk David 2021-04-20 15:45:32 +02:00
parent 7834fcc67d
commit e1a9ba94c5
Notes: blender-bot 2023-10-04 09:42:55 +02:00
Referenced by commit bbb52a462e, Fix T87688: Crash entering valid text into number field
Referenced by issue #87637, Escaping editing a button does not reset change from dragging
1 changed files with 6 additions and 6 deletions

View File

@ -1121,17 +1121,17 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
data->cancel = true;
return;
}
/* If the value entered is the exact same, do not trigger an update. */
if (data->value == data->startvalue) {
data->cancel = true;
return;
}
}
else {
ui_but_value_set(but, data->value);
}
/* If the value entered is the exact same, do not trigger an update. */
if (data->value == data->startvalue) {
data->cancel = true;
return;
}
ui_but_update_edited(but);
ui_apply_but_func(C, but);