diff --git a/source/blender/windowmanager/WM_api.hh b/source/blender/windowmanager/WM_api.hh index 8feb718bfba..0f90cee27d3 100644 --- a/source/blender/windowmanager/WM_api.hh +++ b/source/blender/windowmanager/WM_api.hh @@ -1190,6 +1190,9 @@ std::string WM_operatortype_description_or_name(bContext *C, wmOperatorType *ot, PointerRNA *properties); +/** Check the #OPTYPE_DEPENDS_ON_CURSOR flag and the callback. */ +bool WM_operator_depends_on_cursor(bContext &C, wmOperatorType &ot, PointerRNA *properties); + /* `wm_operator_utils.cc` */ /** diff --git a/source/blender/windowmanager/WM_types.hh b/source/blender/windowmanager/WM_types.hh index 7d32f572b38..3ee68207f9d 100644 --- a/source/blender/windowmanager/WM_types.hh +++ b/source/blender/windowmanager/WM_types.hh @@ -1060,6 +1060,9 @@ struct wmOperatorType { */ std::string (*get_description)(bContext *C, wmOperatorType *ot, PointerRNA *ptr); + /** A dynamic version of #OPTYPE_DEPENDS_ON_CURSOR which can depend on operator properties. */ + bool (*depends_on_cursor)(bContext &C, wmOperatorType &ot, PointerRNA *ptr); + /** RNA for properties. */ StructRNA *srna; diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 89da118247f..5e1b897956a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -1978,7 +1978,7 @@ void WM_operator_name_call_ptr_with_depends_on_cursor(bContext *C, } } - if ((flag & OPTYPE_DEPENDS_ON_CURSOR) == 0) { + if (!WM_operator_depends_on_cursor(*C, *ot, properties)) { WM_operator_name_call_ptr(C, ot, opcontext, properties, event); return; } diff --git a/source/blender/windowmanager/intern/wm_operator_type.cc b/source/blender/windowmanager/intern/wm_operator_type.cc index 19e77a2570d..df8f41181bf 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.cc +++ b/source/blender/windowmanager/intern/wm_operator_type.cc @@ -615,4 +615,15 @@ std::string WM_operatortype_description_or_name(bContext *C, return text; } +bool WM_operator_depends_on_cursor(bContext &C, wmOperatorType &ot, PointerRNA *properties) +{ + if (ot.flag & OPTYPE_DEPENDS_ON_CURSOR) { + return true; + } + if (ot.depends_on_cursor) { + return ot.depends_on_cursor(C, ot, properties); + } + return false; +} + /** \} */