-(void)mouseDown:(NSEvent *)theEvent{
NSPoint point = [self convertPointFromBase:[theEvent locationInWindow]];
if(buttonState!=OV_DISABLE){
if (NSPointInRect(point, buttonImageRect)){
if(buttonState==OV_HOVER){
buttonState=OV_PUSHED;
isPress=YES;
}
[self setNeedsDisplay:YES];
}
}
}
-(void)mouseUp:(NSEvent *)theEvent{
NSPoint point = [self convertPointFromBase:[theEvent locationInWindow]];
if(buttonState!=OV_DISABLE){
if (NSPointInRect(point, buttonImageRect)){
if(buttonState==OV_PUSHED){
buttonState=OV_HOVER;
isPress=NO;
NSDictionary* userInfo=[NSDictionary dictionaryWithObject:theEvent forKey:@"buttonEvent" ];
[[NSNotificationCenter defaultCenter]postNotificationName:@"OverflowButtonIsPressed" object:self userInfo:userInfo];
//[self tabScroll:OV_LEFT :theEvent];
}
}
else buttonState=OV_NORMAL;
[self setNeedsDisplay:YES];
}
}
isPressってのがKVO用に用意していたメンバなわけだが、結局使ってないな。こんな感じでNSEventをNSDictionaryに収めてNotificationを飛ばし、これをTabBarControllerで受ける、と。だいたいこれでTab関係の書き直しが終了したので、本日は新しいプロジェクトを作ってtab関連のファイルをコピーして使えるか試してもみた。
実はこれですごい苦労をした。.xibファイルのコピーって鬼門なのかな。TabBarControllerの- (id)initWithNibName:でKVOのaddObserverが有効にならないし、nib上のViewのメンバを書き換えられなくなった。うーん、と腕を組んだけど- (id)initWithNibName:以外ならIBOutletでつながれたViewにちゃんとアクセスできたのでそれでよしとする。要調査。
0 件のコメント:
コメントを投稿