I have TokenView and TokenDelegate. When select key is entered (WatchUi.KEY_ENTER event) TokenDelegate will launch another view called ConfirmDelete, which is a confirmation dialog. Everything works fine in Simulator, but on real device ConfirmDelete dialog goes away before a user clicks any button.
TokenDelegate:
function onKeyPressed(keyEvent as KeyEvent) as Boolean {
var key = keyEvent.getKey();
System.println("kp " + key);
switch (key) {
case WatchUi.KEY_DOWN:
navigate(true);
return true;
case WatchUi.KEY_UP:
navigate(false);
return true;
case WatchUi.KEY_ENTER:
deleteAccount();
return true;
default:
return false;
}
}
function deleteAccount() as Boolean {
var sel = AccountModel.model.getSelected();
if (sel != 0) {
WatchUi.pushView( new WatchUi.Confirmation("Delete " + sel["a"] + "?"),
new ConfirmDelete(), WatchUi.SLIDE_IMMEDIATE );
return true;
}
return false;
}
ConfirmDelete:
class ConfirmDelete extends Ui.ConfirmationDelegate
{
function initialize() {
Ui.ConfirmationDelegate.initialize();
}
function onResponse(value) {
if (value == CONFIRM_YES) {
var sel = AccountModel.model.getSelected();
if (sel != null) {
var ind = AccountModel.model.getIndByObj(sel);
System.println("byobj: " + ind);
if (AccountModel.model.deleteAccount(sel)) {
AccountModel.model.store();
var newacct = AccountModel.model.getAccountByInd(ind);
if (newacct == null) {
newacct = AccountModel.model.getAccountByInd(ind - 1);
}
var menu = TokenDelegate.createMenu();
if (newacct == null) {
AccountModel.model.selected = "";
}
else {
AccountModel.model.selected = newacct["a"];
// WatchUi.switchToView(new TokenView(), new TokenDelegate(), WatchUi.SLIDE_DOWN);
}
}
}
}
return true;
}
}
class ConfirmReceived extends Ui.ConfirmationDelegate
{
function initialize() {
Ui.ConfirmationDelegate.initialize();
}
function onResponse(value) {
AccountModel.model.selected = "";
var menu = TokenDelegate.createMenu();
WatchUi.switchToView(menu, new MenuDelegate(menu), SLIDE_UP);
return true;
}
}
Garmin tactix-delta-solar video