public class TextControl extends DynamicControlParent
DynamicControl classes of type ControlType.TEXT in a simple API
ControlScope will respond to a message send. For example:
For example, consider two TextControls with the same ControlScope and name
valueChanged(String) listener that is implemented when the class is created.
TextControl control1 = new TextControl(this, "Read", "");
TextControl control2 = new TextControl(this, "Read", "") {
@Override
public void valueChanged(String control_val) {
System.out.println("Read " + control_val);
}
};
control1.setValue("This is text");
valueChanged(String) function to be called with the new value, causing Read This is text to be printed to standard output.
setValue(String, double) function. Eg
ControlScope and name, to "Hi There" 1 second in the future
valueChanged(String) function| Constructor and Description |
|---|
TextControl(java.lang.Object parent_sketch,
java.lang.String name,
java.lang.String initial_value)
Constructor for abstract FloatControl.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getValue()
Get the value for the control.
|
TextControl |
setControlScope(ControlScope new_scope)
Changed the
ControlScope that the control has. |
TextControl |
setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
Change how to display object as
DynamicControl.DISPLAY_TYPE
We must do this in subclass |
void |
setValue(java.lang.String val)
Set the value for the control.
|
void |
setValue(java.lang.String val,
double scheduler_time)
set the value for the control at a specific time.
|
void |
valueChanged(java.lang.String control_val) |
addControlListener, addControlScopeListener, addControlTarget, addControlTarget, clearControlTargets, getDynamicControl, getSendingDevice, removeControlListener, removeControlScopeChangedListener, removeControlTarget, removeControlTarget, removeListeners, setControlTarget, setControlTargetpublic TextControl(java.lang.Object parent_sketch,
java.lang.String name,
java.lang.String initial_value)
parent_sketch - The parent object for controlname - The name to Displayinitial_value - Initial value of the objectpublic java.lang.String getValue()
TextControl control1 = new TextControl(this, "Read", "");
String val = control1.getValue(); // val = ""
control1.setValue("This is text");
val = control1.getValue(); // val = "This is text"
public void valueChanged(java.lang.String control_val)
public void setValue(java.lang.String val)
DynamicControl with matching name, type and ControlScope and call valueChanged(String).
TextControl control1 = new TextControl(this, "Read", "");
TextControl control2 = new TextControl(this, "Read", "") {
@Override
public void valueChanged(String control_val) {
System.out.println("Read " + control_val);
}
};
control1.setValue("This is text");
valueChanged(String) function to be called with the new value, causing Read This is text to be printed to standard output.val - the value to set topublic void setValue(java.lang.String val,
double scheduler_time)
setValue(String) with the exception that the valueChanged(String) event will be caused at the HBScheduler scheduled time passed in.
DynamicControl objects to respond 1 second in the future
control1.setValue ("Hi There", HB.getSchedulerTime() + 1000); // this will set control1 value, as well as all other TextControls with same ControlScope and name, to "Hi There" 1 second in the futureval - the value to set toscheduler_time - the scheduler time this is supposed to occur atpublic TextControl setControlScope(ControlScope new_scope)
ControlScope that the control has. It will update control map so the correct events will be generated based on its scope
We must do this in subclasssetControlScope in class DynamicControlParentnew_scope - The new Control Scopepublic TextControl setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
DynamicControl.DISPLAY_TYPE
We must do this in subclassdisplay_type - The new Display type