Fix T59107: F3 does not work in Python console
authorCampbell Barton <ideasman42@gmail.com>
Mon, 10 Dec 2018 06:33:36 +0000 (17:33 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 10 Dec 2018 06:33:36 +0000 (17:33 +1100)
source/blender/windowmanager/intern/wm_operators.c

index 423d335c78b6b1cbb35d5d2610da4751cc0aa9a8..bdfa13c3ac38744e4a722341d474af9d45b2e624 100644 (file)
@@ -1623,8 +1623,35 @@ static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
+       /* Exception for launching via spacebar */
+       if (event->type == SPACEKEY) {
+               bool ok = true;
+               ScrArea *sa = CTX_wm_area(C);
+               if (sa) {
+                       if (sa->spacetype == SPACE_CONSOLE) {
+                               /* So we can use the shortcut in the console. */
+                               ok = false;
+                       }
+                       else if (sa->spacetype == SPACE_TEXT) {
+                               /* So we can use the spacebar in the text editor. */
+                               ok = false;
+                       }
+               }
+               else {
+                       Object *editob = CTX_data_edit_object(C);
+                       if (editob && editob->type == OB_FONT) {
+                               /* So we can use the spacebar for entering text. */
+                               ok = false;
+                       }
+               }
+               if (!ok) {
+                       return OPERATOR_PASS_THROUGH;
+               }
+       }
+
+
        struct SearchPopupInit_Data data = {
                .size = {
                    UI_searchbox_size_x() * 2,
@@ -1637,26 +1664,6 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
        return OPERATOR_INTERFACE;
 }
 
-/* op->poll */
-static bool wm_search_menu_poll(bContext *C)
-{
-       if (CTX_wm_window(C) == NULL) {
-               return 0;
-       }
-       else {
-               ScrArea *sa = CTX_wm_area(C);
-               if (sa) {
-                       if (sa->spacetype == SPACE_CONSOLE) return 0;  /* XXX - so we can use the shortcut in the console */
-                       if (sa->spacetype == SPACE_TEXT) return 0;     /* XXX - so we can use the spacebar in the text editor */
-               }
-               else {
-                       Object *editob = CTX_data_edit_object(C);
-                       if (editob && editob->type == OB_FONT) return 0;  /* XXX - so we can use the spacebar for entering text */
-               }
-       }
-       return 1;
-}
-
 static void WM_OT_search_menu(wmOperatorType *ot)
 {
        ot->name = "Search Menu";
@@ -1665,7 +1672,7 @@ static void WM_OT_search_menu(wmOperatorType *ot)
 
        ot->invoke = wm_search_menu_invoke;
        ot->exec = wm_search_menu_exec;
-       ot->poll = wm_search_menu_poll;
+       ot->poll = WM_operator_winactive;
 }
 
 static int wm_call_menu_exec(bContext *C, wmOperator *op)