4
$\begingroup$

is it possible to add a custom red text in tooltip ?

here is an example: enter image description here

$\endgroup$
3
$\begingroup$

Currently this feature is not available through the Python API, only for operators implemented in C.

The operator in your screenshot select_ungrouped() is implemented in source\blender\editors\mesh\editmesh_select.c

Operators can use a poll function to check whether they can be executed in the current context. This functionality for select_ungrouped() is implemented in edbm_select_ungrouped_poll(). In this function the message in red is set through:

CTX_wm_operator_poll_msg_set(C, "Must be in vertex selection mode");

Red text in menu

If a message is set through this function and the operator is disabled because poll returns false, it will be displayed beneath the operator's description as a tooltip in the UI. This behavior is implemented in source\blender\editors\interface\interface_region_tooltip.c

The documentation mentions this feature in the Gotchas page.

Blender does have the functionality for poll functions to describe why they fail, but its currently not used much, if you’re interested to help improve our API feel free to add calls to CTX_wm_operator_poll_msg_set where its not obvious why poll fails.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.