home *** CD-ROM | disk | FTP | other *** search
- Notes file for slider program
-
- Objective:
- Learn how to integrate Sliders into your applications.
-
- Terms:
- floatValue method: the method, which is part of the Control Class
- that allows you to get the floating point value from a slider.
-
- Discussion:
- We will create a slider and have it update an internal state variable
- "myFloat". This will be used to update the position of a line in a
- view.
-
- Method:
-
- This is very similar to the previous "line" program, but it
- adds an instance variable "myFloat". We then add a slider
- and have the slider send an "Action Message" to an instance
- the MyView class to tell it to get the new value of the slider.
-
- In this we add an action method to the MyView class called "getSlider:". We then connect the slider up to the View and
- have it send the message "getSlider:".
-
- The getSlider action does the following:
-
- - getSlider:sender
- {
- myFloat =[sender floatValue];
- [self display];
- return self;
- }
-
- In other words, when the slider moves, it updates it internal state
- of the myFloat variable in the view, and then send a message to
- the MyView object (which is just "self") asking it to update the
- display.
-
- If you change the drawSelf to be:
-
- - drawSelf:(NXRect*)r :(int)c
- {
- NXEraseRect(&bounds);
- PSsetgray(NX_BLACK);
- PSsetlinewidth(5.0);
- PSnewpath();
- PSmoveto(bounds.size.width/2.0, 10.0);
- PSlineto(myFloat*1.5, myFloat);
- PSstroke();
- return self;
- }
-
- You will get a circular gauge object that the slider controls.
-
-
- Further Questions:
- Take a look at the Control Class. What other messages can you
- send Controls?
-
- Summary:
-
-
-