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:

http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/eventoverview/handlingmouseevents/handlingmouseevents.html%23//apple_ref/doc/uid/10000060i-ch6-sw18

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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -