I have a bit of an issue with buttons in the toolbar of my slideshow application for Mac.
I want those buttons to be disabled when there is no active slideshow and enabled when there is an active slideshow. In order to achieve this, I set the buttons' isEnabled
property to false
at the start (I have tried both Interface Builder and my window's windowDidLoad
) and then in the didSet
of my slideshow variable I do the following:
var slideshow: Slideshow? {
didSet {
self.playPauseButton.isEnabled = slideshow != nil
}
}
What happens is that the buttons (only one in this example) are enabled for about half a second and then disabled again.
I've set a breakpoint on the didSet
to confirm that slideshow isn't set to nil
at some point. I'm also not modifying isEnabled
anywhere else in my code. For testing I've set isEnabled = true
instead of false
just to see what happens and it turns out the buttons stay enabled then.
Might there be some part of AppKit that automatically disables the buttons for some reason I don't know about? I hope someone might have an idea.