From 1eb557c7efde2fe7dd6a4c976d4604956ac4674d Mon Sep 17 00:00:00 2001 From: Tom Moran <62551154+Tomhausen@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:15:53 +0000 Subject: [PATCH] added function to get property of menu item --- menu.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/menu.ts b/menu.ts index eb5eda5..fb97770 100644 --- a/menu.ts +++ b/menu.ts @@ -1,4 +1,6 @@ +enum MenuItemProperty {Font, Text, Icon} + namespace miniMenu{ /** @@ -27,4 +29,24 @@ namespace miniMenu{ return myMenu } + /** + * Returns a property of a given menu item + */ + //% blockId=getMenuItemProperty + //% block="get $menuItem $property" + //% group="Create" + //% weight=60 + + export function getMenuItemProperty(menuItem: MenuItem, property: MenuItemProperty): any{ + if (property == MenuItemProperty.Font){ + return menuItem.font; + } + else if (property == MenuItemProperty.Text){ + return menuItem.text; + } + else if (property == MenuItemProperty.Icon){ + return menuItem.icon + } + return + } } \ No newline at end of file