How to access a value of the property of the instance
In the event program, you can access the property of the instance by
the method: get/setProperty().
the access method | Description |
WSCvariant getProperty() | get a value of the specified property |
WSCvariant setProperty() | set a value to the specified property |
How to get a value of the properties
You can get a value of the property by the method of WSCbase::getProperty().
public class event_procedure {
protected static void event_procedure(WSCbase object){
// To get a value of the property: "x" by string type.
WSCvariant x = object.getProperty("x");
System.out.println("x=" + x.getCharPtr());
// To get a value of the property: "y" by long type.
WSCvariant y = object.getProperty("y");
System.out.println("y=" + y.getLong());
}
}
In the example of "x", it gets a value by string type.
The WSCstring type manages the buffer of the string automatically,
so there is no need to manage it by programmer.
In the example of "y", it gets a value by short type.
The method: getProperty() returns a value by WSCvariant type.
The WSCvariant type can convert the various kind of type automatically.
Methods of Mwt::WSCvariant | function |
getChar() | To get a value of char type. |
getUnsignedChar() | To get a value of unsigned char type. |
getShort() | To get a value of short type. |
getUnsignedShort() | To get a value of unsigned short type. |
getLong() | To get a value of long type. |
getUnsignedLong() | To get a value of unsigned long type. |
getInt() | To get a value of int type. |
getUnsignedInt() | To get a value of unsigned int type. |
getFloat() | To get a value of float type. |
getDouble() | To get a value of double type. |
getCharPtr() | To get a value of string type. |
Setting of property
You can set a value to the property by the method of WSCbase::setProperty().
public class event_procedure {
protected static void event_procedure(WSCbase object){
// To set a value to the property: "x" by string type.
String x="100";
object.setProperty("x",x);
// To set a value to the property: "y" by short type.
String y=100;
object.setProperty("y",y);
}
}
In the example of "x", it sets a value by string type.
In the example of "y", it sets a value by short type.
The parameter of the method: setProperty() is WSCvariant type,
so it converts the value automatically.
Updating the instance to reflect the changed value
Use the method: update(),draw(),redraw()
to update the instance to reflect the changed value.
public class event_procedure {
protected static void event_procedure(WSCbase object){
newwin000.obj1.setProperty("labelString","string1");
newwin000.obj1.update(); // updates the instance
Mwt.WSGIappDev().update();
newwin000.obj2.setProperty("labelString","string2");
newwin000.obj2.update(); // updates the instance
Mwt.WSGIappDev().update();
}
}
Usually, it updates automatically when the event procedure is done,
but if you want to update right away,you can use the method:
update(),draw(),redraw().
The method: update() or draw() updates the instance if needed,
but redraw() updates compulsory.