Virtual control panel with spring loaded sliders and indicators ...
Virtual control panel with spring loaded sliders and indicators ...
- Subject: Virtual control panel with spring loaded sliders and indicators ...
- From: Danny Ratner <email@hidden>
- Date: Fri, 28 Mar 2003 14:38:48 +1100
Dear all,
I need to develop a spring loaded slider with a text field indicator.
The slider should return to zero when the mouse stops to drag it (mouse
up). The
project is aimed to create a virtual control panel to remotely control
an aerial robot using 4 sliders (some of them without the spring). I am
a beginner with cocoa-Java (but recied help from David Vernon in the
school). Anyone may have experience with building such controller?
We encountered (Java) NSArchiver problem when trying to subclass
NSSlider. When we subclassed NSSliderCell, we managed to create a mouse
up event and bring the slider to zero but could not convey the slider
value to the text field. The text field can move the slider in the
correct way(first image) but the opposite way does not work properly
(we get wrong values in the text field while moving the slider - image
2). The correct values (between 0 to 1) are printed on the status
window (red numbers in image 3), but not in the text field. Screen
images and the Java programs are attached.
If possible, please try to attach modifies Java code that could solve
the problem.
Kind Regards,
Danny Ratner
/* MySliderCell */
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class MySliderCell extends NSSliderCell {
public NSSelector mySelector;
public MySliderCell(){
super ();
mySelector = new NSSelector("setFloatValue", new Class[] {float.class} );
}
public void stopTrackingMouse( NSPoint lastPoint, NSPoint stopPoint, NSView controlView, boolean flag){
System.out.println(floatValue());
if (flag == true)
setFloatValue(0);
}
}
/* Controller */
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class Controller {
public NSSlider mySlider; /* IBOutlet */
public NSTextField text; /* IBOutlet */
public NSWindow myWindow; /* IBOutlet */
private MySliderCell myCell;
private boolean initialised;
private NSSelector mySelector;
public Controller (){
initialised = false;
mySelector = new NSSelector("setFloatValue", new Class[] {float.class} );
myCell = new MySliderCell();
myCell.setContinuous(true);
myCell.setTarget(text);
myCell.setAction(mySelector);
//Must create and set the action (INCODE)
}
public void setField(Object sender) { /* IBAction */
text.setFloatValue(mySlider.floatValue());
}
public void setSlider(Object sender) { /* IBAction */
mySlider.setFloatValue(text.floatValue());
}
public void windowDidBecomeKey(NSNotification aNotification){
if (initialised == false){
mySlider.setCell(myCell);
initialised = true;
}
}
}
[demime 0.98b removed an attachment of type application/pdf which had a name of Picture 1.pdf]
[demime 0.98b removed an attachment of type application/pdf which had a name of Picture 2.pdf]
[demime 0.98b removed an attachment of type application/pdf which had a name of Picture 3.pdf]
Kind Regards,
Danny Ratner
************************************************************************
*******
Dr. Danny Ratner
Ext. 3772 (+61-2-4221-3772)
Home: +61-2-4272-1013
E-mail: email@hidden
Web:
http://www.uow.edu.au/~dannyr/
Intelligent Robotics Laboratory
Bld 3 room 237
School of Information Technology and Computer Science
University of Wollongong
Northfields Avenue
NSW 2522
Australia
************************************************************************
*******
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.