UI: Add reset to default value to keymap
With all the work on DNA defaults for 2.91, it's nice to expose this convenient operator. This was already hardcoded in the UI code to the backspace key, adding it to the keymap instead will make the shortcut automatically show in the button right click menu. Differential Revision: https://developer.blender.org/D9219
This commit is contained in:
parent
d1b3439b80
commit
15d78ea85b
Notes:
blender-bot
2023-02-14 07:31:34 +01:00
Referenced by commit 1504ed99e6
, Fix use after free in interface handler
|
@ -715,6 +715,7 @@ def km_user_interface(_params):
|
|||
("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": True, "alt": True}, None),
|
||||
("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None),
|
||||
("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', "alt": True}, None),
|
||||
("ui.reset_default_button", {"type": 'BACK_SPACE', "value": 'PRESS'}, {"properties": [("all", True)]}),
|
||||
])
|
||||
|
||||
return keymap
|
||||
|
|
|
@ -3123,23 +3123,6 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
|||
return false;
|
||||
}
|
||||
|
||||
void ui_but_default_set(bContext *C, const bool all, const bool use_afterfunc)
|
||||
{
|
||||
wmOperatorType *ot = WM_operatortype_find("UI_OT_reset_default_button", true);
|
||||
|
||||
if (use_afterfunc) {
|
||||
PointerRNA *ptr = ui_handle_afterfunc_add_operator(ot, WM_OP_EXEC_DEFAULT, true);
|
||||
RNA_boolean_set(ptr, "all", all);
|
||||
}
|
||||
else {
|
||||
PointerRNA ptr;
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
RNA_boolean_set(&ptr, "all", all);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &ptr);
|
||||
WM_operator_properties_free(&ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static double soft_range_round_up(double value, double max)
|
||||
{
|
||||
/* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
|
||||
|
|
|
@ -7692,19 +7692,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
|
|||
break;
|
||||
}
|
||||
|
||||
/* reset to default (generic function, only use if not handled by switch above) */
|
||||
/* XXX hardcoded keymap check.... */
|
||||
data = but->active;
|
||||
if (data && data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if ((retval == WM_UI_HANDLER_CONTINUE) &&
|
||||
(event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS)) {
|
||||
/* ctrl+backspace = reset active button; backspace = reset a whole array*/
|
||||
ui_but_default_set(C, !event->ctrl, true);
|
||||
ED_region_tag_redraw(data->region);
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_DRAG_MULTINUM
|
||||
if (data) {
|
||||
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) ||
|
||||
|
|
|
@ -619,8 +619,6 @@ extern uiBut *ui_but_drag_multi_edit_get(uiBut *but);
|
|||
void ui_def_but_icon(uiBut *but, const int icon, const int flag);
|
||||
void ui_def_but_icon_clear(uiBut *but);
|
||||
|
||||
extern void ui_but_default_set(struct bContext *C, const bool all, const bool use_afterfunc);
|
||||
|
||||
void ui_but_extra_operator_icons_free(uiBut *but);
|
||||
|
||||
extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const char *panel_type);
|
||||
|
|
Loading…
Reference in New Issue