UI: Props Dialog Default Properties #119007

Merged
Harley Acheson merged 5 commits from Harley/blender:ProDialogDefProps into main 2024-03-05 18:55:01 +01:00
6 changed files with 15 additions and 8 deletions

View File

@ -1166,8 +1166,9 @@ static int move_to_collection_regular_invoke(bContext *C, wmOperator *op)
static int move_to_new_collection_invoke(bContext *C, wmOperator *op)
{
RNA_string_set(op->ptr, "new_collection_name", IFACE_("Bones"));
Harley marked this conversation as resolved
Review

Could this be done by giving the string property a default value? That seems better than potentially overridint a value remembered from last time or a value set explicitly

Could this be done by giving the string property a default value? That seems better than potentially overridint a value remembered from last time or a value set explicitly
return WM_operator_props_dialog_popup(
C, op, 200, IFACE_("Move to New Collection"), IFACE_("Move"));
C, op, 200, IFACE_("Move to New Bone Collection"), IFACE_("Move"));
}
static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)

View File

@ -5440,6 +5440,11 @@ static int ui_do_but_NUM(
else if (ELEM(event->type, EVT_PADENTER, EVT_RETKEY) && event->val == KM_PRESS) {
click = 1;
}
else if (event->type == EVT_BUT_OPEN) {
/* Handle UI_but_focus_on_enter_event. */
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
retval = WM_UI_HANDLER_BREAK;
}
else if (event->type == EVT_MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;

View File

@ -2816,7 +2816,7 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
* - this is used for allowing operators with popups to rename stuff with fewer clicks
*/
if (is_popup) {
if ((but->rnaprop == op->type->prop) && (but->type == UI_BTYPE_TEXT)) {
if ((but->rnaprop == op->type->prop) && (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM))) {
UI_but_focus_on_enter_event(CTX_wm_window(C), but);
}
}

View File

@ -2683,7 +2683,8 @@ void IMAGE_OT_new(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_string(ot->srna, "name", IMA_DEF_NAME, MAX_ID_NAME - 2, "Name", "Image data-block name");
ot->prop = RNA_def_string(
ot->srna, "name", IMA_DEF_NAME, MAX_ID_NAME - 2, "Name", "Image data-block name");
prop = RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384);
RNA_def_property_subtype(prop, PROP_PIXEL);
prop = RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);

View File

@ -2460,8 +2460,6 @@ static int text_jump_invoke(bContext *C, wmOperator *op, const wmEvent * /*event
void TEXT_OT_jump(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Jump";
ot->idname = "TEXT_OT_jump";
@ -2473,8 +2471,9 @@ void TEXT_OT_jump(wmOperatorType *ot)
ot->poll = text_edit_poll;
/* properties */
prop = RNA_def_int(ot->srna, "line", 1, 1, INT_MAX, "Line", "Line number to jump to", 1, 10000);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT);
ot->prop = RNA_def_int(
ot->srna, "line", 1, 1, INT_MAX, "Line", "Line number to jump to", 1, 10000);
RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_TEXT);
}
/** \} */

View File

@ -1842,7 +1842,8 @@ static void WM_OT_debug_menu(wmOperatorType *ot)
ot->exec = wm_debug_menu_exec;
ot->poll = WM_operator_winactive;
RNA_def_int(ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000);
ot->prop = RNA_def_int(
ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000);
}
/** \} */