[Bf-blender-cvs] [2580d2bab50] master: PyAPI: Expose event.type_prev, value_prev

Campbell Barton noreply at git.blender.org
Fri Jun 24 15:21:01 CEST 2022


Commit: 2580d2bab50f399f101095a197301229614b1d48
Author: Campbell Barton
Date:   Fri Jun 24 23:10:51 2022 +1000
Branches: master
https://developer.blender.org/rB2580d2bab50f399f101095a197301229614b1d48

PyAPI: Expose event.type_prev, value_prev

Before [0] mouse-motion events left the 'event.value' un-changed,
so a mouse-move would be set to PRESS/RELEASE based on previous events.

Support accessing the previous event value directly
to address feedback from T99102.

Note that the previous cursor location is already exposed.

[0]: 52af3b20d45ea525a0ce66b2613ac132c9032a3f

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

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 3ff9e6be3ce..47cc61510c6 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -2065,6 +2065,12 @@ static void rna_def_event(BlenderRNA *brna)
   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, "value_prev", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "prev_val");
+  RNA_def_property_enum_items(prop, rna_enum_event_value_items);
+  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+  RNA_def_property_ui_text(prop, "Previous 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, rna_enum_event_type_items);
@@ -2072,6 +2078,13 @@ static void rna_def_event(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
   RNA_def_property_ui_text(prop, "Type", "");
 
+  prop = RNA_def_property(srna, "type_prev", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "prev_type");
+  RNA_def_property_enum_items(prop, rna_enum_event_type_items);
+  RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
+  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+  RNA_def_property_ui_text(prop, "Previous Type", "");
+
   prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "direction");
   RNA_def_property_enum_items(prop, rna_enum_event_direction_items);



More information about the Bf-blender-cvs mailing list