Hi,
Which is the best way to show a pop-up message on a EDGE data field?
Is there any method?
Thanks in advance,
Oriol
Hi,
Which is the best way to show a pop-up message on a EDGE data field?
Is there any method?
Thanks in advance,
Oriol
A general, universal way to do it is this. When a lap is triggered, a message is displayed for about 5 seconds. Otherwise, it displays the elapsed seconds.
using Toybox.WatchUi;
using Toybox.Graphics;
class popdfView extends WatchUi.DataField {
var width,height;
var elapsedSec=0;
var lapPopup=0;
var lapPopupTime=5;
function initialize() {
DataField.initialize();
}
function onTimerLap() {
lapPopup=lapPopupTime;
}
function onLayout(dc) {
width=dc.getWidth();
height=dc.getHeight();
}
function compute(info) {
if(info.elapsedTime!=null) {elapsedSec=info.elapsedTime/1000;}
}
function onUpdate(dc) {
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
dc.clear();
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
var message="";
if(lapPopup==0) {
message=elapsedSec.toNumber();
} else {
lapPopup--;
message="new lap";
}
dc.drawText(width/2,height/2, Graphics.FONT_SMALL,message,Graphics.TEXT_JUSTIFY_CENTER|Graphics.TEXT_JUSTIFY_VCENTER);
}
}: