Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-03-06 09:24:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-03-06 09:31:28 +0300
commit5be0e3430d13341feddee739997130239daf71d5 (patch)
treeb8af4c1d47d40425d0703883f8efdc0c297e37ea /source/blender/makesrna/intern/rna_wm.c
parent73ef27f15611ccb254816e199f8c74103b3d5172 (diff)
GHOST/Keymap: support for detecting repeat events
- Keymap items now have 'repeat' boolean which can be set to make keymap items respond to key repeat events or not. - Support for X11 & WIN32 (not macOS currently). This allows for the possibility to perform actions while a key is held and finish the action upon release. Thanks to @Severin for review and WIN32 support.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index bf3c562f95f..929540f10ac 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -652,6 +652,12 @@ static int rna_Event_unicode_length(PointerRNA *ptr)
}
}
+static bool rna_Event_is_repeat_get(PointerRNA *ptr)
+{
+ const wmEvent *event = ptr->data;
+ return event->is_repeat;
+}
+
static float rna_Event_pressure_get(PointerRNA *ptr)
{
const wmEvent *event = ptr->data;
@@ -2131,6 +2137,12 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "");
+ /* keyboard */
+ prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_boolean_funcs(prop, "rna_Event_is_repeat_get", NULL);
+ RNA_def_property_ui_text(prop, "Is Repeat", "The event is generated by holding a key down");
+
/* mouse */
prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "x");
@@ -2728,6 +2740,12 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+ prop = RNA_def_property(srna, "repeat", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_REPEAT_IGNORE);
+ RNA_def_property_ui_text(prop, "Repeat", "Active on key-repeat events (when a key is held)");
+ RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);