Started this week looking to Connect IQ SDk, so i decided to build a small app just to test how things work.
The app, it's a simple calculator, just to do something useful.
My first problem, after designing all the buttons, what's the best approach to put everything in place and detect selections on each button.
1 - I know that i can define every button in the resources, then load and place them in the View, and with the tap event detect which button was touched, but it doesn't looks like very professional and very efficient.
2 - I can create a layout, and define all the bitmaps, and set the x,y coordinate and everything just get placed in the right place, but once again i have to detect the tap event and where.
3 - I can create a resource file where every bitmap is inside a drawable, and then place the id in the layout to draw everything in the view.
For what i read in the docs, i can use the selectable event, in the 3 approaches that i wrote, the third it's the only that can use the selectable? Or any of them can use it, but need some kind of tweak?
Now for testing i have this:
<drawables>
<bitmap id="LauncherIcon" filename="launcher_icon.png" />
<drawable-list id="background">
<shape type="rectangle" x="0" y="0" width="fill" height="fill" color="Gfx.COLOR_GREEN"></shape>
</drawable-list>
<drawable-list id="Number0">
<bitmap id="Number_0" x="15" y="15" filename="../drawables/N0.png"></bitmap>
</drawable-list>...
And this:
<layout id="MainLayout">
<drawable id="background" />
<drawable id="Number0" />
...
And i have some code for the tap events:
class CalcDelegate extends Ui.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
}
function onTap(evt){
var clickEvt = evt;
System.println(">>>TAP: " + clickEvt.getCoordinates() + " >>> " + clickEvt.getType());
}
function onKey( evt ){
System.println(">>>KEY: " + evt.getKey());
}
}
It's this correct?
And now, what's the minimum that i have to do, to make the app detect the touchs in every button (numbers and operations)?
Thanks