Hello! I want to share with you something I found to make creating custom menus easier. This piece of code uses the menu button. scene.systemMenu.addEntry(() => string, () => handler, image)
How to use:
Replace string with the name
Replace handler with the code
Replace image with the icon
Here is how you can use it as an extension:
//% color="#e6ac00" icon="" block="Menu"
namespace menu {
//% block="Add system menu option $name icon $image function:"
//% handlerStatement=1
//% image.shadow=screen_image_picker
export function addmenuoption(name: string, image: Image, handler: () => void): void {
scene.systemMenu.addEntry(() => name, handler, image);
}
}
Yeah! All you have to do to create an extention is to go to javascript, then press the plus button:
Name your extention whatever you want, then import the code below.
To export it so you can turn it into a sharable extension is to press the github icon in the bottom of the screen next to the project title, then follow the directions it gives you.
Wow amazing, I thought making extensions was much more complicated :0 I could totally use the samples you gave, learn a bit, and make my text to speech into an extension !!
Have you considered putting this on GitHub so people can import it easier into their projects? If you don’t know how, I can show you- but anyways very good extension, I can see myself using this
Sure! Sorry for the late response, I haven’t checked the forum in awhile. For anyone who needs it, here is the link to the extension: https://github.com/meeeeeeeep1/custom-systemmenu-options/. Scroll down to the bottom of the page for instructions on how to import it into your projects.
Great news! I’ve fixed the error that occurred when opening the menu. Additionally, I found a neat trick to retrieve the title of any menu option. Simply use scene.systemMenu.buildOptionList()[option index].getText().