Custom Menu Showcase

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:

  1. Replace string with the name
  2. Replace handler with the code
  3. Replace image with the icon

Screenshot 2023-03-09 at 21-54-17 Microsoft MakeCode Arcade

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);

    }
}

11 Likes

Woah! This Is Cool! I never knew you could add Stuff to The System Menu!

2 Likes

Wow thanks for the tutorial! Is there any way to export the extension?

1 Like

Yeah! All you have to do to create an extention is to go to javascript, then press the plus button:
image
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.

2 Likes

cool I did this back with three brave cats 2 Three Brave Cats 2: Return to the Sea
but the way you did it prevents you form just coding in Js to do it

3 Likes

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 !!

sorry you had missed one string of code:)

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);

}
}
1 Like

Agreed

This is Cool. Good Job @meeeeeeeep1 :+1:

I did it! I am going to have so much fun with this

3 Likes

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

2 Likes

Noice!

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.

3 Likes

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().

1 Like