Following the instructions in WatchUi.Button, I have put together most of the parameters to build a button by hand.
In onLayout()
if ( mySettings.isTouchScreen ) {
var b_zout = {
:locX => 0,
:locY => 20,
:width => 50,
:height => 50,
:behavior => :btnZoomOut
};
var tsButton = new Button.initialize(b_zout);
setLayout(tsButton);
}
In MyBehaviorDelegate
class MyBehaviorDelegate extends Ui.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
}
function btnZoomOut() {
if (true) {
// do stuff;
Ui.requestUpdate();
}
return true;
}
}I appear to be having problems with the right format for the :behavior parameter in the dictionary. I have tried the following formats with the associated results.
:behavior => :btnZoomOut = UnexpectedTypeException: Expected Class definition, given Method
:behavior => MyBehaviorDelegate.btnZoomOut = UnexpectedTypeException: Expected Class definition, given Method
:behavior => MyBehaviorDelegate.btnZoomOut() = UnexpectedTypeException: Expected Class definition, given Method
:behavior => btnZoomOut() = Could not find symbol btnZoomOut.
:behavior => btnZoomOut = Could not find symbol btnZoomOut.
So there is obviously a proper way to format the behavior method that is not clear to me. Every example I can find is using the XML layout method, so I have not see an good example.
Any one have an idea? I know I can stick with the XML, but now it is bugging me to figure this one out.