forked from bartvdbraak/blender
Text3d: add select all operator
also add Edit menu for 3d text and move cut/copy/paste there.
This commit is contained in:
parent
1c8d1569da
commit
42aa19088e
@ -51,7 +51,7 @@ class VIEW3D_HT_header(Header):
|
||||
sub.menu("VIEW3D_MT_select_paint_mask")
|
||||
elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
|
||||
sub.menu("VIEW3D_MT_select_paint_mask_vertex")
|
||||
elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
|
||||
elif mode_string not in {'SCULPT'}:
|
||||
sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
|
||||
|
||||
if mode_string == 'OBJECT':
|
||||
@ -714,6 +714,23 @@ class VIEW3D_MT_select_edit_surface(Menu):
|
||||
layout.operator("curve.select_less")
|
||||
|
||||
|
||||
class VIEW3D_MT_select_edit_text(Menu):
|
||||
# intentional name mis-match
|
||||
# select menu for 3d-text doesn't make sense
|
||||
bl_label = "Edit"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("font.text_copy", text="Copy")
|
||||
layout.operator("font.text_cut", text="Cut")
|
||||
layout.operator("font.text_paste", text="Paste")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("font.select_all")
|
||||
|
||||
|
||||
class VIEW3D_MT_select_edit_metaball(Menu):
|
||||
bl_label = "Select"
|
||||
|
||||
|
@ -346,12 +346,6 @@ class VIEW3D_PT_tools_textedit(View3DPanel, Panel):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Text Edit:")
|
||||
col.operator("font.text_copy", text="Copy")
|
||||
col.operator("font.text_cut", text="Cut")
|
||||
col.operator("font.text_paste", text="Paste")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Set Case:")
|
||||
col.operator("font.case_set", text="To Upper").case = 'UPPER'
|
||||
|
@ -56,6 +56,8 @@ void FONT_OT_case_set(struct wmOperatorType *ot);
|
||||
void FONT_OT_style_toggle(struct wmOperatorType *ot);
|
||||
void FONT_OT_style_set(struct wmOperatorType *ot);
|
||||
|
||||
void FONT_OT_select_all(struct wmOperatorType *ot);
|
||||
|
||||
void FONT_OT_text_copy(struct wmOperatorType *ot);
|
||||
void FONT_OT_text_cut(struct wmOperatorType *ot);
|
||||
void FONT_OT_text_paste(struct wmOperatorType *ot);
|
||||
|
@ -65,6 +65,8 @@ void ED_operatortypes_curve(void)
|
||||
WM_operatortype_append(FONT_OT_style_toggle);
|
||||
WM_operatortype_append(FONT_OT_style_set);
|
||||
|
||||
WM_operatortype_append(FONT_OT_select_all);
|
||||
|
||||
WM_operatortype_append(FONT_OT_text_copy);
|
||||
WM_operatortype_append(FONT_OT_text_cut);
|
||||
WM_operatortype_append(FONT_OT_text_paste);
|
||||
@ -208,6 +210,8 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", UPARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1);
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", DOWNARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1);
|
||||
|
||||
WM_keymap_add_item(keymap, "FONT_OT_select_all", AKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
@ -675,6 +675,47 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
|
||||
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to");
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Select All */
|
||||
|
||||
static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Curve *cu = obedit->data;
|
||||
|
||||
if (cu->len) {
|
||||
cu->selstart = 1;
|
||||
cu->selend = cu->len;
|
||||
cu->pos = cu->len;
|
||||
|
||||
text_update_edited(C, scene, obedit, true, FO_SELCHANGE);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FONT_OT_select_all(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Select All";
|
||||
ot->description = "Select all text";
|
||||
ot->idname = "FONT_OT_select_all";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = font_select_all_exec;
|
||||
ot->poll = ED_operator_editfont;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
/******************* copy text operator ********************/
|
||||
|
||||
static void copy_selection(Object *obedit)
|
||||
|
Loading…
Reference in New Issue
Block a user