Fix T40538: Multi-button canceling edit-text could leave edited value

This commit is contained in:
Campbell Barton 2014-06-09 15:35:34 +10:00
parent b707b07c5b
commit c04c6a3b83
Notes: blender-bot 2023-12-22 20:14:11 +01:00
Referenced by issue #40538, Multi-button dragging/editing glitches
1 changed files with 17 additions and 5 deletions

View File

@ -2372,6 +2372,18 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
data->str = NULL;
}
#ifdef USE_DRAG_MULTINUM
/* this can happen from multi-drag */
if (data->applied_interactive) {
/* remove any small changes so canceling edit doesn't restore invalid value: T40538 */
data->cancel = true;
ui_apply_button(C, but->block, but, data, true);
data->cancel = false;
data->applied_interactive = false;
}
#endif
/* retrieve string */
data->maxlen = ui_get_but_string_max_length(but);
data->str = MEM_callocN(sizeof(char) * data->maxlen + 1, "textedit str");
@ -2392,11 +2404,6 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
data->selextend = 0;
data->selstartx = 0.0f;
#ifdef USE_DRAG_MULTINUM
/* this can happen from multi-drag */
data->applied_interactive = false;
#endif
/* set cursor pos to the end of the text */
but->editstr = data->str;
but->pos = len;
@ -3308,6 +3315,11 @@ static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data,
if (data->draglock) {
if (abs(mx - data->dragstartx) <= 3)
return changed;
#ifdef USE_DRAG_MULTINUM
if (ELEM(data->multi_data.init, BUTTON_MULTI_INIT_UNSET, BUTTON_MULTI_INIT_SETUP)) {
return changed;
}
#endif
data->draglock = false;
data->dragstartx = mx; /* ignore mouse movement within drag-lock */