사용자 지정 컨트롤을 만듭니다. 여기에 내 사용자 지정 컨트롤을 위해 할 작업은 다음과 같습니다
먼저 인터페이스 :
@interface AS_CustomControl : NSControl <NSCoding>
{
}
@end
그런 구현 :
@implementation AS_CustomControl
-(id)initWithFrame:(NSRect)rect
{
if (self = [super initWithFrame:rect])
{
[self initCustomControl];
}
return self;
}
-(id)initWithCoder:(NSCoder*)coder
{
if (self = [super initWithCoder:coder])
{
[self initCustomControl];
}
return self;
}
-(void)initCustomControl
{
// put any custom initialization here
// such as default variable state
}
-(void)dealloc
{
[super dealloc];
}
-(void)encodeWithCoder:(NSCoder*)coder
{
[super encodeWithCoder:coder];
}
+(Class)cellClass
{
return [NSActionCell class];
}
@end
cellClass 방법은 사용자 지정 컨트롤 액션 메시지를 발사 것을 보장 할 때 사용자 그것과 상호 작용합니다.
그런 다음 파형을 drawRect :에 그리는 경우와 mouseDown : mouseDragged : 및 mouseUp : 메시지를 재정 의하여 범위 선택을 처리해야합니다.
음악에 대한 귀하의 취향에 +1. – yuji
나에게 슬라이더처럼 보이지 않습니다. 나는 그것이 사용자 정의 컨트롤이라고 생각합니다. –