Skip to content

Commit

Permalink
added function to get property of menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomhausen committed Feb 26, 2024
1 parent 59eabf6 commit 1eb557c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

enum MenuItemProperty {Font, Text, Icon}

namespace miniMenu{

/**
Expand Down Expand Up @@ -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
}
}

0 comments on commit 1eb557c

Please sign in to comment.