I want to create a custom switch for my application, in which I put three images for possible states (on, off, mousedown). The whole view is contained in the images, so I do not want Cocoa to highlight (darken) the button during mousedown.
At this point, I have created a subclass of NSButtonCell, dragged the NSButtonTypeMomentaryChange slash button into my view, and custom set the button cell class type for my subclass. The subclass simply implements awakeFromNib to try to set the desired behavior:
- (void)awakeFromNib { [self setShowsStateBy:NSContentsCellMask]; [self setHighlightsBy:NSContentsCellMask]; }
which, as I thought (according to the documentation), would disable the dimming of the buttonβs darkening. This is not true.
This is where I stand, and now I have two questions:
- How can I set the ButtonCell class to just show the prepared picture on mousedown and not obscure / draw the borders around the button?
- What will be the cleanest / most appropriate way to implement different switch behavior, i.e. displaying the off / on position depending on the previous state and the ability to correctly communicate your state to other objects?
source share