From 7f55c3b89c67a17d454389815be313b4c66f34b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Jun 2009 14:30:59 +0000 Subject: RNA read-only wrapped wmEvent so python operators invoke functions * 2 new enums event_value_items and event_type_items in RNA_enum_types.h * WM_key_event_string now uses an RNA enum lookup rather then its own switch statement. * moved wmEvent from WM_types.h into DNA_windowmanager_types.h * added RNA_enum_identifier and RNA_enum_name to get strings from an enum value. --- source/blender/editors/transform/transform_input.c | 1 + .../editors/transform/transform_ndofinput.c | 1 + .../blender/editors/transform/transform_numinput.c | 1 + source/blender/makesdna/DNA_windowmanager_types.h | 31 ++ source/blender/makesrna/RNA_access.h | 4 + source/blender/makesrna/RNA_enum_types.h | 3 + source/blender/makesrna/intern/rna_access.c | 31 +- source/blender/makesrna/intern/rna_wm.c | 202 +++++++++++++ source/blender/python/intern/bpy_operator_wrap.c | 97 +------ source/blender/windowmanager/WM_types.h | 31 -- source/blender/windowmanager/intern/wm_keymap.c | 311 +-------------------- 11 files changed, 274 insertions(+), 439 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 4d721a83c78..76b3f58f75c 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -26,6 +26,7 @@ #include #include "DNA_screen_types.h" +#include "DNA_windowmanager_types.h" #include "BLI_arithb.h" diff --git a/source/blender/editors/transform/transform_ndofinput.c b/source/blender/editors/transform/transform_ndofinput.c index c52492ebd6b..9c2a1a7db6d 100644 --- a/source/blender/editors/transform/transform_ndofinput.c +++ b/source/blender/editors/transform/transform_ndofinput.c @@ -31,6 +31,7 @@ #include "BKE_utildefines.h" /* ABS */ #include "DNA_view3d_types.h" /* for G.vd (view3d) */ +#include "DNA_windowmanager_types.h" /* for G.vd (view3d) */ #include "WM_types.h" diff --git a/source/blender/editors/transform/transform_numinput.c b/source/blender/editors/transform/transform_numinput.c index 34976105db3..f5f1d5fac9e 100644 --- a/source/blender/editors/transform/transform_numinput.c +++ b/source/blender/editors/transform/transform_numinput.c @@ -34,6 +34,7 @@ #include "BKE_utildefines.h" /* ABS */ #include "WM_types.h" +#include "DNA_windowmanager_types.h" #include "transform.h" diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 7d6b5ec8764..e02d2984771 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -222,5 +222,36 @@ typedef enum wmRadialControlMode { WM_RADIALCONTROL_ANGLE } wmRadialControlMode; +/* ************** wmEvent ************************ */ +/* for read-only rna access, dont save this */ + +/* each event should have full modifier state */ +/* event comes from eventmanager and from keymap */ +typedef struct wmEvent { + struct wmEvent *next, *prev; + + short type; /* event code itself (short, is also in keymap) */ + short val; /* press, release, scrollvalue */ + short x, y; /* mouse pointer position, screen coord */ + short mval[2]; /* region mouse position, name convention pre 2.5 :) */ + short prevx, prevy; /* previous mouse pointer position */ + short unicode; /* future, ghost? */ + char ascii; /* from ghost */ + char pad; + + /* modifier states */ + short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ + short keymodifier; /* rawkey modifier */ + + /* keymap item, set by handler (weak?) */ + const char *keymap_idname; + + /* custom data */ + short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ + void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ + short customdatafree; + +} wmEvent; + #endif /* DNA_WINDOWMANAGER_TYPES_H */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 9b653bd924a..4a074ab1546 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -172,6 +172,7 @@ extern StructRNA RNA_EnvironmentMap; extern StructRNA RNA_EnvironmentMapTexture; extern StructRNA RNA_ExplodeModifier; extern StructRNA RNA_ExpressionController; +extern StructRNA RNA_Event; extern StructRNA RNA_FCurve; extern StructRNA RNA_FModifier; extern StructRNA RNA_FModifierCycles; @@ -541,6 +542,9 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin, void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax); void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision); +int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier); +int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name); + void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem); int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value); int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index c679d9fc544..276f421c586 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -40,6 +40,9 @@ extern EnumPropertyItem beztriple_interpolation_mode_items[]; extern EnumPropertyItem fmodifier_type_items[]; +extern EnumPropertyItem event_value_items[]; +extern EnumPropertyItem event_type_items[]; + #endif /* RNA_ENUM_TYPES */ diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index ba893319ce9..13686809cd2 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -669,6 +669,28 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden return 0; } +int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier) +{ + for (; item->identifier; item++) { + if(item->value==value) { + *identifier = item->identifier; + return 1; + } + } + return 0; +} + +int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name) +{ + for (; item->identifier; item++) { + if(item->value==value) { + *name = item->name; + return 1; + } + } + return 0; +} + int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier) { const EnumPropertyItem *item; @@ -676,14 +698,7 @@ int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int v RNA_property_enum_items(ptr, prop, &item, &totitem); - for(i=0; iproperties); } + +static int rna_Event_ascii_get(PointerRNA *ptr, char *value) +{ + wmEvent *event= (wmEvent*)ptr->id.data; + value[0]= event->ascii; + value[1]= '\0'; +} + +static int rna_Event_ascii_length(PointerRNA *ptr) +{ + wmEvent *event= (wmEvent*)ptr->id.data; + return (event->ascii)? 1 : 0; +} + #else static void rna_def_operator(BlenderRNA *brna) @@ -146,7 +274,80 @@ static void rna_def_operator_filelist_element(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_ui_text(prop, "Name", "the name of a file or directory within a file list"); } + +static void rna_def_event(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "Event", NULL); + RNA_def_struct_ui_text(srna, "Event", "Window Manager Event"); + RNA_def_struct_sdna(srna, "wmEvent"); + + /* strings */ + prop= RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL); + RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event."); + + + /* enums */ + prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "val"); + RNA_def_property_enum_items(prop, event_value_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some."); + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Type", ""); + + + /* mouse */ + prop= RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "x"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse."); + + prop= RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "y"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse."); + + prop= RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "prevx"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse."); + + prop= RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "prevy"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse."); + + /* modifiers */ + prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shift", 1); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Shift", "True when the shift key is held."); + + prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Ctrl", "True when the shift key is held."); + + prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "alt", 1); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Alt", "True when the shift key is held."); + + prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "OS Key", "True when the shift key is held."); +} static void rna_def_windowmanager(BlenderRNA *brna) { @@ -169,6 +370,7 @@ void RNA_def_wm(BlenderRNA *brna) rna_def_operator(brna); rna_def_operator_utils(brna); rna_def_operator_filelist_element(brna); + rna_def_event(brna); rna_def_windowmanager(brna); } diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index f4fdd0c6194..542de6bd9b8 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -47,98 +47,6 @@ #define PYOP_ATTR_IDNAME "__name__" /* use pythons class name */ #define PYOP_ATTR_DESCRIPTION "__doc__" /* use pythons docstring */ -static PyObject *pyop_dict_from_event(wmEvent *event) -{ - PyObject *dict= PyDict_New(); - PyObject *item; - char *cstring, ascii[2]; - - /* type */ - item= PyUnicode_FromString(WM_key_event_string(event->type)); - PyDict_SetItemString(dict, "type", item); Py_DECREF(item); - - /* val */ - switch(event->val) { - case KM_ANY: - cstring = "ANY"; - break; - case KM_RELEASE: - cstring = "RELEASE"; - break; - case KM_PRESS: - cstring = "PRESS"; - break; - default: - cstring = "UNKNOWN"; - break; - } - - item= PyUnicode_FromString(cstring); - PyDict_SetItemString(dict, "val", item); Py_DECREF(item); - - /* x, y (mouse) */ - item= PyLong_FromLong(event->x); - PyDict_SetItemString(dict, "x", item); Py_DECREF(item); - - item= PyLong_FromLong(event->y); - PyDict_SetItemString(dict, "y", item); Py_DECREF(item); - - item= PyLong_FromLong(event->prevx); - PyDict_SetItemString(dict, "prevx", item); Py_DECREF(item); - - item= PyLong_FromLong(event->prevy); - PyDict_SetItemString(dict, "prevy", item); Py_DECREF(item); - - /* ascii */ - ascii[0]= event->ascii; - ascii[1]= '\0'; - item= PyUnicode_FromString(ascii); - PyDict_SetItemString(dict, "ascii", item); Py_DECREF(item); - - /* modifier keys */ - item= PyLong_FromLong(event->shift); - PyDict_SetItemString(dict, "shift", item); Py_DECREF(item); - - item= PyLong_FromLong(event->ctrl); - PyDict_SetItemString(dict, "ctrl", item); Py_DECREF(item); - - item= PyLong_FromLong(event->alt); - PyDict_SetItemString(dict, "alt", item); Py_DECREF(item); - - item= PyLong_FromLong(event->oskey); - PyDict_SetItemString(dict, "oskey", item); Py_DECREF(item); - - - - /* modifier */ -#if 0 - item= PyTuple_New(0); - if(event->keymodifier & KM_SHIFT) { - _PyTuple_Resize(&item, size+1); - PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("SHIFT")); - size++; - } - if(event->keymodifier & KM_CTRL) { - _PyTuple_Resize(&item, size+1); - PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("CTRL")); - size++; - } - if(event->keymodifier & KM_ALT) { - _PyTuple_Resize(&item, size+1); - PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("ALT")); - size++; - } - if(event->keymodifier & KM_OSKEY) { - _PyTuple_Resize(&item, size+1); - PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("OSKEY")); - size++; - } - PyDict_SetItemString(dict, "keymodifier", item); Py_DECREF(item); -#endif - - return dict; -} - static struct BPY_flag_def pyop_ret_flags[] = { {"RUNNING_MODAL", OPERATOR_RUNNING_MODAL}, {"CANCELLED", OPERATOR_CANCELLED}, @@ -180,6 +88,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve int ret_flag= (mode==PYOP_POLL ? 0:OPERATOR_CANCELLED); PointerRNA ptr_context; PointerRNA ptr_operator; + PointerRNA ptr_event; PyObject *py_operator; PyGILState_STATE gilstate = PyGILState_Ensure(); @@ -230,11 +139,13 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve if (mode==PYOP_INVOKE) { item= PyObject_GetAttrString(py_class, "invoke"); args = PyTuple_New(3); + + RNA_pointer_create(NULL, &RNA_Event, event, &ptr_event); // PyTuple_SET_ITEM "steals" object reference, it is // an object passed shouldn't be DECREF'ed PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context)); - PyTuple_SET_ITEM(args, 2, pyop_dict_from_event(event)); + PyTuple_SET_ITEM(args, 2, pyrna_struct_CreatePyObject(&ptr_event)); } else if (mode==PYOP_EXEC) { item= PyObject_GetAttrString(py_class, "execute"); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 739cfbcc1ac..9b987cdfa51 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -58,37 +58,6 @@ enum { WM_OP_EXEC_SCREEN }; -/* ************** wmEvent ************************ */ - -/* each event should have full modifier state */ -/* event comes from eventmanager and from keymap */ -typedef struct wmEvent { - struct wmEvent *next, *prev; - - short type; /* event code itself (short, is also in keymap) */ - short val; /* press, release, scrollvalue */ - short x, y; /* mouse pointer position, screen coord */ - short mval[2]; /* region mouse position, name convention pre 2.5 :) */ - short prevx, prevy; /* previous mouse pointer position */ - short unicode; /* future, ghost? */ - char ascii; /* from ghost */ - char pad; - - /* modifier states */ - short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ - short keymodifier; /* rawkey modifier */ - - /* keymap item, set by handler (weak?) */ - const char *keymap_idname; - - /* custom data */ - short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ - void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ - short customdatafree; - -} wmEvent; - - /* ************** wmKeyMap ************************ */ /* modifier */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 7528321c7c5..85028e3ea1a 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -44,6 +44,7 @@ #include "RNA_access.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -155,313 +156,9 @@ ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, int spacei char *WM_key_event_string(short type) { - /* not returned: CAPSLOCKKEY, UNKNOWNKEY, COMMANDKEY, GRLESSKEY */ - - switch(type) { - case AKEY: - return "A"; - break; - case BKEY: - return "B"; - break; - case CKEY: - return "C"; - break; - case DKEY: - return "D"; - break; - case EKEY: - return "E"; - break; - case FKEY: - return "F"; - break; - case GKEY: - return "G"; - break; - case HKEY: - return "H"; - break; - case IKEY: - return "I"; - break; - case JKEY: - return "J"; - break; - case KKEY: - return "K"; - break; - case LKEY: - return "L"; - break; - case MKEY: - return "M"; - break; - case NKEY: - return "N"; - break; - case OKEY: - return "O"; - break; - case PKEY: - return "P"; - break; - case QKEY: - return "Q"; - break; - case RKEY: - return "R"; - break; - case SKEY: - return "S"; - break; - case TKEY: - return "T"; - break; - case UKEY: - return "U"; - break; - case VKEY: - return "V"; - break; - case WKEY: - return "W"; - break; - case XKEY: - return "X"; - break; - case YKEY: - return "Y"; - break; - case ZKEY: - return "Z"; - break; - - case ZEROKEY: - return "Zero"; - break; - case ONEKEY: - return "One"; - break; - case TWOKEY: - return "Two"; - break; - case THREEKEY: - return "Three"; - break; - case FOURKEY: - return "Four"; - break; - case FIVEKEY: - return "Five"; - break; - case SIXKEY: - return "Six"; - break; - case SEVENKEY: - return "Seven"; - break; - case EIGHTKEY: - return "Eight"; - break; - case NINEKEY: - return "Nine"; - break; - - case LEFTCTRLKEY: - return "Leftctrl"; - break; - case LEFTALTKEY: - return "Leftalt"; - break; - case RIGHTALTKEY: - return "Rightalt"; - break; - case RIGHTCTRLKEY: - return "Rightctrl"; - break; - case RIGHTSHIFTKEY: - return "Rightshift"; - break; - case LEFTSHIFTKEY: - return "Leftshift"; - break; - - case ESCKEY: - return "Esc"; - break; - case TABKEY: - return "Tab"; - break; - case RETKEY: - return "Ret"; - break; - case SPACEKEY: - return "Space"; - break; - case LINEFEEDKEY: - return "Linefeed"; - break; - case BACKSPACEKEY: - return "Backspace"; - break; - case DELKEY: - return "Del"; - break; - case SEMICOLONKEY: - return "Semicolon"; - break; - case PERIODKEY: - return "Period"; - break; - case COMMAKEY: - return "Comma"; - break; - case QUOTEKEY: - return "Quote"; - break; - case ACCENTGRAVEKEY: - return "Accentgrave"; - break; - case MINUSKEY: - return "Minus"; - break; - case SLASHKEY: - return "Slash"; - break; - case BACKSLASHKEY: - return "Backslash"; - break; - case EQUALKEY: - return "Equal"; - break; - case LEFTBRACKETKEY: - return "Leftbracket"; - break; - case RIGHTBRACKETKEY: - return "Rightbracket"; - break; - - case LEFTARROWKEY: - return "Leftarrow"; - break; - case DOWNARROWKEY: - return "Downarrow"; - break; - case RIGHTARROWKEY: - return "Rightarrow"; - break; - case UPARROWKEY: - return "Uparrow"; - break; - - case PAD2: - return "Numpad 2"; - break; - case PAD4: - return "Numpad 4"; - break; - case PAD6: - return "Numpad 6"; - break; - case PAD8: - return "Numpad 8"; - break; - case PAD1: - return "Numpad 1"; - break; - case PAD3: - return "Numpad 3"; - break; - case PAD5: - return "Numpad 5"; - break; - case PAD7: - return "Numpad 7"; - break; - case PAD9: - return "Numpad 9"; - break; - - case PADPERIOD: - return "Numpad ."; - break; - case PADSLASHKEY: - return "Numpad /"; - break; - case PADASTERKEY: - return "Numpad *"; - break; - - case PAD0: - return "Numpad 0"; - break; - case PADMINUS: - return "Numpad -"; - break; - case PADENTER: - return "Numpad Enter"; - break; - case PADPLUSKEY: - return "Numpad +"; - break; - - case F1KEY: - return "F1"; - break; - case F2KEY: - return "F2"; - break; - case F3KEY: - return "F3"; - break; - case F4KEY: - return "F4"; - break; - case F5KEY: - return "F5"; - break; - case F6KEY: - return "F6"; - break; - case F7KEY: - return "F7"; - break; - case F8KEY: - return "F8"; - break; - case F9KEY: - return "F9"; - break; - case F10KEY: - return "F10"; - break; - case F11KEY: - return "F11"; - break; - case F12KEY: - return "F12"; - break; - - case PAUSEKEY: - return "Pause"; - break; - case INSERTKEY: - return "Insert"; - break; - case HOMEKEY: - return "Home"; - break; - case PAGEUPKEY: - return "Pageup"; - break; - case PAGEDOWNKEY: - return "Pagedown"; - break; - case ENDKEY: - return "End"; - break; - } + const char *name= NULL; + if(RNA_enum_name(event_type_items, (int)type, &name)) + return name; return ""; } -- cgit v1.2.3