How is the NSWindow's instance variable isVisible updated?

Hello,

Consider this method :

    on switchUtilityWindow_(sender)
        if theUtilityWindow's isVisible then
           theUtilityWindow's orderOut_(me)
        else
           theUtilityWindow's makeKeyAndOrderFront_(me)
        end if
    end switchUtilityWindow_

This method can be called either by a button on another window, or by a menu command. When you switch the utility window only from the menu bar, it switches correctly. When you switch it only by the button, it’s ok too. But if you alternate between button and menu command, it’s like there were TWO isVisible instance variables: the switch action “pass one turn”.

Maybe I make something wrong. but it’s weird anyway.

Note that the result is the same with:

if (inspectorPanel's isVisible())as integer is 1 then

or by prefixing theUtilityWindow’s with “my”.