RE: Subclassing NSSlider and NSSliderCell
RE: Subclassing NSSlider and NSSliderCell
- Subject: RE: Subclassing NSSlider and NSSliderCell
- From: Vinay Prabhu <email@hidden>
- Date: Tue, 23 May 2006 15:08:06 +0530
- Importance: Normal
I got the problem with the earlier code.
The following piece of code,
SliderCell* temp;
temp = [self cell];
[temp setParent:self];
shouldn't be in the +(void)initialize method.
Declare one more function in the Slider(subclass of NSSlider) and place the
above code here.
Call this function from your controller class. Work done.
It works properly here.
Thanks for the help.
Regards
Vinay
-----Original Message-----
I am able to display the knob properly, and also I am able to customize the
appearance of knob.
>if there is a instance variable declared as: int someVariable;
>try
>int a = [super someVariable];
>int a = [super getSomeVariable];
>[super setSomeVariable:a];
The above method doesn't work.
Because the "super" here is the NSSliderCell.
But I want to access the member variables of the subclass of the NSSlider,
which I have used to create the slider.
I have tries something, but it didn't work. Please have a look, confirm it
is proper
In the Slider class subclass of NSSlider
+ (void)initialize
{
[Slider setCellClass:[SliderCell class]];
SliderCell* temp;
temp = [self cell];
[temp setParent:self];
}
SliderCell is the subclass of NSSliderCell,
-(void)setParent:(Slider*)slider
{
mySlider = slider;
}
mySlider is the object of class Slider.
Here I am trying to create a object of type Slider inside the SliderCell, so
that
I can use it later.
I am not too sure, what I am doing will work.
Regards
Vinay
-----Original Message-----
From: Lon Giese [mailto:email@hidden]
Sent: Tuesday, May 23, 2006 1:21 PM
To: Vinay Prabhu
Subject: Re: Subclassing NSSlider and NSSliderCell
Is this about drawing you knob? did you get the knob to display
properly yet?
super class instance variables should be accessed through accessor
methods so :
if there is a instance variable declared as: int someVariable;
try
int a = [super someVariable];
int a = [super getSomeVariable];
[super setSomeVariable:a];
If that doesn't recheck the documentation if there is an indirect way
to access that variable.
if that does not work try using the variable directly (not advisable,
but if you have no choice?)
Then you need to ask someone who knows more than me, like ask apple to
make an accessor method...
On May 22, 2006, at 10:44 PM, Vinay Prabhu wrote:
> Hi,
>
> I am designing a application, where it is required to
> customize the slider appearance.
> So I have subclassed NSSliderCell, by following code in the
> subclass of NSSlider,
> + (void)initialize
> {
> [Slider setCellClass:[SliderCell class]];
> }
> This works fine, and "drawKnob" is successfully overridden.
>
> There are few member variables declared in the subclass of
> NSSlider class, which needs to be accessed when "drawKnob" is
> called.
> I am not sure how to get access those member variables.
> Thanks in advance.
>
> Regards
> Vinay
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> addressee(s)and may contain confidential or privileged information. If
> you are not the intended recipient, please notify the sender or
> email@hidden
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> email@hidden
>
> This email sent to email@hidden
>
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s)and may
contain confidential or privileged information. If you are not the intended
recipient, please notify the sender or email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
in
This email sent to email@hidden
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s)and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender or email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden