- Define a subclass of Drawable
class GraphDrawable extends Drawable {
function initialize(params) {
Drawable.initialize(params);
}
function draw(dc) { ... }
} - Define a layout that references the custom Drawable
<layout id="MainLayout" ...>
<drawable id="my_id" class"GraphDrawable" />
</layout> - Set layout in your View
class GraphDataField extends Ui.DataField {
function onLayout(dc) {
setLayout(Rez.Layouts.MainLayout(dc));
}
}
Expected behavior: The class is initialized without error
Observed behavior: App (a data field) crashes with error:
Unexpected Type Error
in initialize (/Users/charpentier/garmin/git/toolchain/mbsimulator/submodules/technology/monkeybrains/virtual-machine/api/WatchUi.mb:1269)
Workaround:
Define at least one param element inside the drawable definition:
<layout id="MainLayout" ...>
<drawable id="my_id" class"GraphDrawable">
<param name="locX">0</param>
<param name="locY">0</param>
</drawable>
</layout>