cocoa - mouseDragged: is not passed down two subviews? -


i writing program has number of subclassed nsviews (frame) varying contents can dragged around mouse in superview. of views contain 1 subview, called contentview, in turn can contain more complicated hierarchy.

if have non-editable nstextfield contentview mousedown: , mousedragged: events passed on superview without problem , dragging works fine.

mousedown:    ---> [nstextfield] ---> [frame] mousedragged: ---> [nstextfield] ---> [frame] 

if contentview subclass of nsview in turn contains number of nstextfields mousedragged: event not passed on nstextfields superview.

mousedown:    ---> [nstextfield] ---> [subclassed nsview] ---> [frame] mousedragged: ---> [nstextfield] -x->  

the mousedown: event received frame. clicking in gaps between nstextfields , dragging contentview directly works @ well.

the nstextfields set in contentview:

nstextfield *textfield = [[nstextfield alloc] initwithframe:rect]; [textfield setbordered:no]; [textfield setselectable:no]; [textfield seteditable:no]; [textfield settextcolor:[nscolor blackcolor]]; [textfield setbackgroundcolor:[nscolor clearcolor]]; [textfield setdrawsbackground:no]; [textfield setalignment:nsrighttextalignment]; [textfield setfont:[nsfont fontwithname:@"helvetica" size:14]]; [self addsubview:textfield]; [textfield release]; 

i have tried adding mousedragged: method both subclassed nstextfield , subclassed nsview, leaving method out. neither made difference. problem exists other nscontrols @ same subview level.

- (void)mousedragged:(nsevent *)theevent {     [super mousedragged:theevent]; } 

or

- (void)mousedragged:(nsevent *)theevent {     [self.superview mousedragged:theevent]; } 

at moment behaviour seems unintuitive me. there missing? (i working xcode 4.6.2 on mountain lion.)

nstextview has special handling mouse. not sure nstextfield, might exhibit same behaviour. instance there's no mouseup event. mousedown event enters local loop (probably dragging content). try overwrite mousedown in class , call nsview's mousedown circumvent nstextfield's mouse down. see this question how this.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -