Hey,
If you add a using statement for WatchUi.DataField to your module it should work. The module is self contained so it doesn't have access to the extension of WatchUi.DataField in your TESTView class. When you call doDSP.sendDisplay() and you hit the Datafield.findDrawableById() call, we can't find the symbol because it has not been pulled into the module.
Thanks,
-Coleman
using Toybox.Graphics; // this isn't required by the compiler right now, but it really seems that it should be
module doDsp {
function sendDisplay(var dataField) {
var valueView = dataField.findDrawableById("value");
var labelView = dataField.findDrawableById("label");
var bgView = dataField.findDrawableById("Background");
var bgColor = dataField.getBackgroundColor();
var fgColor = Graphics.COLOR_DK_BLUE;
valueView.setFont(Graphics.FONT_LARGE);
bgView.setColor(bgColor);
labelView.setColor(fgColor);
valueView.setColor(fgColor);
labelView.setText("MyLabel");
valueView.setText("MyLabel");
}
}
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
class MyDataFieldImpl
{
function initialize() {
}
function getLabelText() {
return "MyLabel";
}
function getValueText() {
return "MyValue";
}
}
class MyDataField extends Ui.DataField
{
hidden var impl_;
function initialize(impl) {
DataField.initialize();
impl_ = impl;
}
function onLayout(dc) {
// things that don't change after initialization be in here...
DataField.setLayout(Rez.Layouts.MainLayout(dc));
}
function onUpdate(dc) {
// only things that can change after initialization should be in here...
var bgColor = DataField.getBackgroundColor();
var fgColor = Gfx.COLOR_DK_BLUE;
var background = DataField.findDrawableById("Background");
background.setColor(bgColor);
var label = DataField.findDrawableById("label");
label.setColor(fgColor);
var value = DataField.findDrawableById("value");
value.setFont(Gfx.FONT_LARGE);
value.setColor(fgColor);
// delegate to implementation for the text
label.setText(impl_.getLabelText());
value.setText(impl_.getValueText());
DataField.onUpdate(dc);
}
}
class MyDataField extends Ui.DataField {
hidden var impl_;
function initialize(impl) {
DataField.initialize();
impl_ = impl;
}
}
[/code]