How to prevent widget click open

Hello everyone.

I would like to put a current widget into a disable state so that the widget cannot be clicked until certain conditions are met.

I know that registerCommand has a function called isEnabeld, but this just prevents the Command from being used,
I have tried simply returning onActiveRequest() in the widget class, but it still opens the widget when clicked.

In what way can I solve this problem?

The attached picture shows the clicks I want to prevent.
capture1