Added two new options to menu items

1. The ability to disable a menu item without deleting it.
2. The option to quit the application on item selection.
This commit is contained in:
Philip Abbey
2025-07-08 22:48:42 +01:00
parent 659a060c76
commit ec044c5408
4 changed files with 50 additions and 24 deletions

View File

@ -23,6 +23,7 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
private var mHomeAssistantService as HomeAssistantService;
private var mService as Lang.String or Null;
private var mConfirm as Lang.Boolean;
private var mExit as Lang.Boolean;
private var mPin as Lang.Boolean;
private var mData as Lang.Dictionary or Null;
@ -43,9 +44,10 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
label as Lang.String or Lang.Symbol,
template as Lang.String,
service as Lang.String or Null,
data as Lang.Dictionary or Null,
exit as Lang.Boolean,
confirm as Lang.Boolean,
pin as Lang.Boolean,
data as Lang.Dictionary or Null,
icon as Graphics.BitmapType or WatchUi.Drawable,
options as {
:alignment as WatchUi.MenuItem.Alignment,
@ -67,9 +69,10 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
mHomeAssistantService = haService;
mService = service;
mData = data;
mExit = exit;
mConfirm = confirm;
mPin = pin;
mData = data;
}
//! Call a Home Assistant service only after checks have been done for confirmation or PIN entry.
@ -105,6 +108,9 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
if (mService != null) {
mHomeAssistantService.call(mService, mData);
}
if (mExit) {
System.exit();
}
}
}