[Bf-blender-cvs] [13b283ca8e0] property-search-ui: Property Search: Make ctrl-F work, and alt-F to clear

Hans Goudey noreply at git.blender.org
Tue Jun 16 17:54:46 CEST 2020


Commit: 13b283ca8e041b5450423f8c756a8b021e096540
Author: Hans Goudey
Date:   Tue Jun 16 11:54:38 2020 -0400
Branches: property-search-ui
https://developer.blender.org/rB13b283ca8e041b5450423f8c756a8b021e096540

Property Search: Make ctrl-F work, and alt-F to clear

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/space_buttons/buttons_intern.h
M	source/blender/editors/space_buttons/buttons_ops.c
M	source/blender/editors/space_buttons/space_buttons.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bd6b1b1d3e5..19c19f8c2da 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -726,6 +726,7 @@ def km_property_editor(_params):
         ("screen.space_context_cycle", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
          {"properties": [("direction", 'NEXT'), ], },),
         ("buttons.start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
+        ("buttons.clear_filter", {"type": 'F', "value": 'PRESS', "alt": True}, None),
     ])
 
     return keymap
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 3bf1b449601..ce6490f6baa 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -91,6 +91,7 @@ void buttons_texture_context_compute(const struct bContext *C, struct SpacePrope
 
 /* buttons_ops.c */
 void BUTTONS_OT_start_filter(struct wmOperatorType *ot);
+void BUTTONS_OT_clear_filter(struct wmOperatorType *ot);
 void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
 void BUTTONS_OT_directory_browse(struct wmOperatorType *ot);
 void BUTTONS_OT_context_menu(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index d65fec3f741..15eef56c650 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -58,10 +58,15 @@
 
 static int buttons_start_filter_exec(bContext *C, wmOperator *UNUSED(op))
 {
-  ARegion *region = CTX_wm_region(C);
   SpaceProperties *space = CTX_wm_space_properties(C);
+  ScrArea *area = CTX_wm_area(C);
+  ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
 
+  ARegion *region_ctx = CTX_wm_region(C);
+  CTX_wm_region_set(C, region);
   UI_textbutton_activate_rna(C, region, space, "filter_text");
+  CTX_wm_region_set(C, region_ctx);
+
   return OPERATOR_FINISHED;
 }
 
@@ -77,6 +82,32 @@ void BUTTONS_OT_start_filter(struct wmOperatorType *ot)
   ot->poll = ED_operator_buttons_active;
 }
 
+/********************** clear filter operator *********************/
+
+static int buttons_clear_filter_exec(bContext *C, wmOperator *UNUSED(op))
+{
+  ScrArea *area = CTX_wm_area(C);
+  SpaceProperties *space = CTX_wm_space_properties(C);
+
+  strcpy(space->search_string, "");
+
+  ED_area_tag_redraw(area);
+
+  return OPERATOR_FINISHED;
+}
+
+void BUTTONS_OT_clear_filter(struct wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Clear Filter";
+  ot->description = "Clear the search filter";
+  ot->idname = "BUTTONS_OT_clear_filter";
+
+  /* api callbacks */
+  ot->exec = buttons_clear_filter_exec;
+  ot->poll = ED_operator_buttons_active;
+}
+
 /********************** context_menu operator *********************/
 
 static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index bfbd3974191..b55d70d5bba 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -243,6 +243,7 @@ static void buttons_main_region_listener(wmWindow *UNUSED(win),
 static void buttons_operatortypes(void)
 {
   WM_operatortype_append(BUTTONS_OT_start_filter);
+  WM_operatortype_append(BUTTONS_OT_clear_filter);
   WM_operatortype_append(BUTTONS_OT_context_menu);
   WM_operatortype_append(BUTTONS_OT_file_browse);
   WM_operatortype_append(BUTTONS_OT_directory_browse);



More information about the Bf-blender-cvs mailing list