My Custom Common Event Menu closes entirely in any scene with cancel button instead of going back one page only.

Hi, first time posting here.
I watched some tutorial and tried making a custom menu based off common events but I ran into a problem.
The custom menu instantly closes itself the moment I pressed x(cancel) button instead of going back to main menu first.
No matter what scene I was in like item/skills it instantly closes all of it by pressing the cancel button.
The common event is in the image, is there any solution to this?
Cancel close all.jpg
events can only be processed on map or in battle, no other scene has an interpreter to process event commands.
if for example you have an item with an attached common event, then on using that item the engine will close the item menu and bring you back to the map before the common event is started.

no matter which scene you command open with the scene manager command, the second you need to continue processing the event commands (even for a break loop) you have to be back oin the map first.

You either have to make those other menues with event commands only (never using the scenemanager script), or you need a plugin that installs an interpreter for the menues.
You can turn on a switch every time your menu opens, and add another common event that will run in the background and force open the menu on the map scene while that switch is on. Turn off the switch when you close your menu.
This will keep your menu open as long as you're in the map scene.
So, the problem is probably that you're quitting those menus by pressing X, which is still pressed when your event starts running again, therefore instantly activating the If button [Cancel] is pressed down branch.
Most reasonable solution is probably to ensure that a new keypress is needed to exit your menu. You can achieve this, for example, by setting a switch before pushing a new scene. Then, adding another conditional that disables that switch if the Cancel button is not pressed. And finally, only break the loop if the Cancel button is pressed and the switch is off. This will ensure that the keypress that you used to exit the scene won't affect your menu, since you're first waiting for it to be released.

EDIT:
no other scene has an interpreter to process event commands
Not that it's relevant here, but Scene_Title does have one 😉
Sorry for the late reply, been busy.
I'm new to rpg maker so all the terms went past my head but after searching interpreter in the script call list I figured out how to do it.
I also managed to make the picture call the SceneManager when it's clicked with triacontane PictureCallCommon plugin.
Thanks, you all!
there is another problem when button is 0, variable = 2, which is
incorrect as you have 4 buttons, but I see other issues.

I have a evented main menu where you can look at, it doesn't freeze
the player, but I made one to do so (not in the evented menu), but I might
upgrade it a bit for a more fancy evented menu.

you can if you press cancel to keep the main menu open (depending
on the scene you are in), if the menu is the only thing open, it does erase
itself.

there are some ways to build it, on map, or a seperate map with the menu active,
this however require 2 more parallels to navigate and a remember position.

you can compare yours with mine how I did set up the menu, so you can improve
yours to your liking.
there is another problem when button is 0, variable = 2, which is
incorrect as you have 4 buttons, but I see other issues.

I have a evented main menu where you can look at, it doesn't freeze
the player, but I made one to do so (not in the evented menu), but I might
upgrade it a bit for a more fancy evented menu.

you can if you press cancel to keep the main menu open (depending
on the scene you are in), if the menu is the only thing open, it does erase
itself.

there are some ways to build it, on map, or a seperate map with the menu active,
this however require 2 more parallels to navigate and a remember position.

you can compare yours with mine how I did set up the menu, so you can improve
yours to your liking.
1. ShadowDragon_MC (Menu Customiser) Version 0.1.0
This one?
I will check later, thank you.
the evented menu in my spoiler, MC is a plugin and is being changed as well.
which is for a single actor menu, but it can make things easier if you use a
single actor and not multiple actors as it doesn't have a status scene.

the evented way can be found [here] which is under tutorials.

Original thread: https://forums.rpgmakerweb.com/threads/my-custom-common-event-menu-closes-entirely-in-any-scene-with-cancel-button-instead-of-going-back-one-page-only.162236/