[Bf-blender-cvs] [ba44919601c] master: Fix Event.value RNA access with tweak event types

Campbell Barton noreply at git.blender.org
Wed Jan 13 10:03:04 CET 2021


Commit: ba44919601c540218ce05765915689d3837b8420
Author: Campbell Barton
Date:   Wed Jan 13 19:35:30 2021 +1100
Branches: master
https://developer.blender.org/rBba44919601c540218ce05765915689d3837b8420

Fix Event.value RNA access with tweak event types

Accessing event.value would return unrelated values such as
PRESS, RELEASE, CLICK... etc. instead of NORTH, SOUTH... etc.

===================================================================

M	source/blender/makesrna/intern/rna_wm.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 1d833024823..e9b31b1d8b9 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -606,6 +606,18 @@ static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, ot->srna, otmacro->properties);
 }
 
+static const EnumPropertyItem *rna_Event_value_itemf(bContext *UNUSED(C),
+                                                     PointerRNA *ptr,
+                                                     PropertyRNA *UNUSED(prop),
+                                                     bool *UNUSED(r_free))
+{
+  const wmEvent *event = ptr->data;
+  if (ISTWEAK(event->type)) {
+    return event_tweak_value_items;
+  }
+  return rna_enum_event_value_items;
+}
+
 static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
 {
   const wmEvent *event = ptr->data;
@@ -2113,6 +2125,7 @@ static void rna_def_event(BlenderRNA *brna)
   prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "val");
   RNA_def_property_enum_items(prop, rna_enum_event_value_items);
+  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Event_value_itemf");
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
   RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");



More information about the Bf-blender-cvs mailing list