If you need to perform any actions just before the window closes, connect the aboutToCloseWidget event of the Window part to an action in your part.
If you need to perform any actions just before the window opens, connect the aboutToOpenWidget event of the Window part to an action in your part.
The gettingFocus event acts differently depending on which part is receiving the event. For example, if you connect the gettingFocus event to a Window part, the window will come to the foreground and be the active window. Also, if you connect the gettingFocus event to a Text part in a window, the cursor is moved to this field.