Whenever a panel opens or closes - do something

Hello all,

I’d like to execute a function whenever a panel opens and closes.
This can be the search panel or the gotoLine panel or any panel.

Do you have any hints how this can be achieved?
I cannot dispatch something when a keyboard shortcut is pressed as the keyboard shortcut opening the panel is unknown.

Thank you in advance for your help!
Simon

You could compare the value of the showPanel facet in the previous state and the new state.

Thank you @marijn , that helped me to resolve the issue!

I have another slightly related issue.
I’m monitoring the showPanel facet and am saving open panels in a global array.
When pressing Escape within the Editor ALL those panels should close.
How can I achieve that?

You can’t. The extension that provides the panel determines whether it is open or closed, so you’d need to get those to cooperate.