osx - Redrawing NSButton when mouseDown and mouseUp -
i subclassing nsbutton
, perform custom drawing. imlement methods -mousedown
, -mouseup
. when perform short(fast) click, code work perfect, if hold down left mouse button time release it, method -mouseup
didn't work. perhaps don't understand how buttons work... want buttons change appearance when mouse down, , return previous when goes up. wrong?
the reason getting behavior there 2 different ways handle mouse dragging in cocoa. both discussed here:
nsbutton using "the mouse-tracking loop approach", (including mouse-up event) done within mousedown:
method. in case wondering about, how things in nsbutton
subclass:
- (void)mousedown:(nsevent *)event { someivar = no; [super mousedown:event]; //sometimes, when here, have had "mouse up" //because super's mousedown did everything. //to find out if case, 1 solution put //an instance variable subclass (someivar) if (someivar == yes) { //you have "mouse up" } else { //you don't have "mouse up" } } - (void)mousedragged:(nsevent *)event { someivar = yes; }
Comments
Post a Comment