MV (SOLVED) Press Shift to Force Close Choice Box

Hello,

I'm trying to code my own very basic menu using 'Show Choices' functions to open up menu boxes and I would like to know how I would be able to force close specific choice boxes with the Shift key possibly with a script call before the 'Show Choices' function in a common event? Any help would be appreciated, thank you!
look for a plugin "choice options" to disable or hide specific parts of a choice on defined conditions.
I think both tsukihime and yanfly have such plugins for MV
look for a plugin "choice options" to disable or hide specific parts of a choice on defined conditions.
I think both tsukihime and yanfly have such plugins for MV
Thank you for the reply but I am looking to close the entire choice box rather then to disable or hide specific parts of a choice, very similar to the 'Cancel' options for the choice box, except instead of setting a 'Cancel' option for that choice, it closes it down by pressing the Shift key.
If you're OK using the normal Cancel input (e.g. Esc/X) then you can just add an empty "Cancel" branch using the event command, e.g.

◆Show Choices:Yes, No (Window, Right, #1, -) :When Yes ◆Text:None, Window, Bottom : :Yes ◆ :When No ◆Text:None, Window, Bottom : :No ◆ :When Cancel ◆Comment:Nothing ◆ :End
I.e. when cancel is pressed, the choices close and the event moves onto its next command (if any).

If it's important to use Shift for this then I think you'll need a plugin. In that case, do you want to:
  1. Make Shift the only "cancel" input for choices?

  2. Add Shift as another "cancel" input for choices?

  3. Make Shift close the choice list, with no change to the existing Cancel options?

  4. Something else?
"Cancel" already has the function of closing a choice box (if you allow it when setting up the box), so if I wanted the shift key to be able to do this, then I would set the function of the shift key to be "Cancel". You can do this by keymapping the shift key, with a script that runs once at the start of your game:

Code:
Input.keyMapper[16] = 'cancel'

(The number is the JS key code for the shift key - you can find the key codes for different keys on the keyboard here: https://keycode.info/ )

The above should give the shift key the cancel function. However, this is permanent unless you change it mid-game (i.e. with another event and/or conditional). If you want the function of the shift key to change based on circumstances (e.g. if a choice menu is open or not), you can:

  1. Create a switch that turns on whenever a menu is opened.
  2. Have a constantly-running, parallel common event (i.e. a "main loop") check to see if this "menu is open" switch is on - if it is, then have the "main loop" common event run the script above to keymap the shift key to have the "cancel" function.
  3. Have an "else" branch in the conditional check from Step 2 that then keymaps the shift key back to whatever function you want it to have for the rest of the game (i.e. if the "menu is open" switch is not on).
  4. To turn the switch off, just use Control Switches in the "When Cancel" branch of the choice box setup, and it should automatically turn off when the menu is closed.

That is how I would do it. I'm not at my home computer right now so I can't test this specifically, but I've done very similar things in my game and they have all worked well.

Good luck!
If you're OK using the normal Cancel input (e.g. Esc/X) then you can just add an empty "Cancel" branch using the event command, e.g.

◆Show Choices:Yes, No (Window, Right, #1, -) :When Yes ◆Text:None, Window, Bottom : :Yes ◆ :When No ◆Text:None, Window, Bottom : :No ◆ :When Cancel ◆Comment:Nothing ◆ :End

I.e. when cancel is pressed, the choices close and the event moves onto its next command (if any).

If it's important to use Shift for this then I think you'll need a plugin. In that case, do you want to:
  1. Make Shift the only "cancel" input for choices?

  2. Add Shift as another "cancel" input for choices?

  3. Make Shift close the choice list, with no change to the existing Cancel options?

  4. Something else?
I do think I need a plugin for this. I was looking for something like 3, but to only close for that exact choice and not be able to close the other choices with Shift.
I do think I need a plugin for this. I was looking for something like 3, but to only close for that exact choice and not be able to close the other choices with Shift.

Do you mean to have multiple choice boxes open and shift only closes one of them, or do you mean to have just one choice box but shift only closes it if a certain choice within it is highlighted?
Do you mean to have multiple choice boxes open and shift only closes one of them, or do you mean to have just one choice box but shift only closes it if a certain choice within it is highlighted?
I mean the player has the ability to close that particular choice box without needing to select anything, just pressing the Shift key.
@RancidPast So there would be multiple choice boxes open at the same time (in which case you could simply disallow cancelling for those boxes you don't want to be closed)? Were you able to understand what I described in my first response, and does that sound like it would work for what you're thinking?

EDIT: I guess I would just like a clearer idea of exactly what your menu will look like, because it could affect whether you would actually need a plugin or could probably get by using the script/eventing I described above. Do you have screenshots of what you have currently? Depending on your exact setup and exactly how you want it to work, I may even be able to alter the plan I described to work a little differently, if needed 😛 Unless you would find it easier to just find a plugin.
@RancidPast So there would be multiple choice boxes open at the same time (in which case you could simply disallow cancelling for those boxes you don't want to be closed)? Were you able to understand what I described in my first response, and does that sound like it would work for what you're thinking?
I understand the idea, I was trying to have a parallel process happen with the common event for the choice menu as well but I want it to detect that the menu is open then close the menu using the Shift key without the need to use the Cancel functionality. I want it to be separate thing from other choices too.
I understand the idea, I was trying to have a parallel process happen with the common event for the choice menu as well but I want it to detect that the menu is open then close the menu using the Shift key without the need to use the Cancel functionality. I want it to be separate thing from other choices too.

Is there a reason you don't want to utilize the cancel functionality to close the choice box? To be clear, if you keymap the shift key to 'cancel' and set everything up the way I described, the outcome should be that the player can just press shift and it will close without having to select any option whatsoever. And the purpose of the switch is to detect when the menu is open so you can control when this functionality is available.

If you try it and it doesn't work, then that's one thing and I can re-look it over! But have you tried actually implementing it yet? I think it should do what you seem to want it to do.
Is there a reason you don't want to utilize the cancel functionality to close the choice box? To be clear, if you keymap the shift key to 'cancel' and set everything up the way I described, the outcome should be that the player can just press shift and it will close without having to select any option whatsoever. And the purpose of the switch is to detect when the menu is open so you can control when this functionality is available.

If you try it and it doesn't work, then that's one thing and I can re-look it over! But have you tried actually implementing it yet? I think it should do what you seem to want it to do.
I'm not trying to be frustrating here but I really need it to be a separate process from the 'Cancel' functionality of the choice menu.
I'm not trying to be frustrating here but I really need it to be a separate process from the 'Cancel' functionality of the choice menu.

Hmm... okay, let me see what I can find 🙂 I just got home, so I can actually play around with RPG Maker now. I think all you'd need then (to avoid using the cancel branch of the choice menu) is a script to directly close the choice menu, and instead of mapping the shift key to "cancel" you'd just name it something else (like "shift" or "closemenu"), and instead of utilizing the built-in cancel function you'd just have to add one extra step to check for shift being pressed and then tell it what to do (i.e. close the choices box, presumably with a script). I just have to find that script.

Gimme just a few mins to look around! (I can also now simulate and test it myself and send screenshots if it works)

EDIT: Oh hey I realized shift is already a default button you can check in RMMV, so actually no need to keymap it at all if you're not changing its function to cancel. (I'm still trying things though, need more time)
Hmm... okay, let me see what I can find 🙂 I just got home, so I can actually play around with RPG Maker now. I think all you'd need then (to avoid using the cancel branch of the choice menu) is a script to directly close the choice menu, and instead of mapping the shift key to "cancel" you'd just name it something else (like "shift" or "closemenu"), and instead of utilizing the built-in cancel function you'd just have to add one extra step to check for shift being pressed and then tell it what to do (i.e. close the choices box, presumably with a script). I just have to find that script.

Gimme just a few mins to look around! (I can also now simulate and test it myself and send screenshots if it works)
Thank you very much for helping, that would be great if you can show me a script that would work in that way. ☺️
I'm not trying to be frustrating here but I really need it to be a separate process from the 'Cancel' functionality of the choice menu.
why?
we are confused because in several posts you demand things that are already in the engine without any plugin at all.
for example
I was looking for something like 3, but to only close for that exact choice and not be able to close the other choices with Shift.
that sounds as if you want a cancel with a specific result, and that is already in the event command as the cancel choice. Please look at the right side of the "show choices" command window.
there you can specify what should happen on the regular cancel (which means which of the choices should be executed if the cancel button is pressed, or forbid cancelling, or make its own branch that is neither choice

Please tell us what exactly you want to happen that cannot be prepared in this setting when changing the general key mapped to cancel.
Because everything you described so far can be done this way.
@Andar Yeah, I kind of want more details, too. I'm getting stuck trying to figure out how to force close a choice window without utilizing the "cancel" function, because as it turns out, parallel processes don't run while it's open, so you can't rely on one to check for a button press and close it from the outside.

@RancidPast If you absolutely cannot use the cancel branch of the choice window to be triggered with a re-mapped shift key, then I don't think there is a way to do it without a plugin, after all. But I'm even having a hard time finding a plugin that will do that. I found some stuff about timed choices, but that isn't what you need.

Sorry! I tried 🙁 But that's also why we would like more detail... because it's possible that my original solution could still work after all, but we need to understand why you can't use the cancel function (e.g. are you already using it for something else? or, are there other windows open at the same time that you don't want to also close?), to see whether there is or isn't a different way to set this all up to make it work.
But I'm even having a hard time finding a plugin that will do that.
you won't find one because that goes against too many default eventing functions.
he would need a custom plugin specifically designed to work that way.

but for such a custom plugin we are back to needing better descriptions, because the currently given descriptions are not detailed enough.

My honest opinion though?
I think the OP started to program that evented menu without fully understanding all options available through eventing, then made a number of bad choices trying to work around limitations that only exist because he didn't know better, and now has a logic structure that can't work at all but needs a redesign of the internal logic to work.

If he can get a full description up that would either proof otherwise by showing a working logic, or force him to admit that it required a logic redesign.
you won't find one because that goes against too many default eventing functions.
he would need a custom plugin specifically designed to work that way.

but for such a custom plugin we are back to needing better descriptions, because the currently given descriptions are not detailed enough.

My honest opinion though?
I think the OP started to program that evented menu without fully understanding all options available through eventing, then made a number of bad choices trying to work around limitations that only exist because he didn't know better, and now has a logic structure that can't work at all but needs a redesign of the internal logic to work.

If he can get a full description up that would either proof otherwise by showing a working logic, or force him to admit that it required a logic redesign.
It seems that you are a tiny bit perturbed by my recent forum posts. I don't understand why you insist on describing me getting help on the RPG Maker help forum as "demanding things" when I am doing what many forum users are doing and have been doing since these forums have been used.

I have spent many hours working on the code on my own and scrolling through most, if not all, active RPG Maker websites and forums for even vaguely related questions/solutions to my problem. I have always and will always use this forum as the nuclear option if I am genuinely stumped as to how to code something into the game as I know how frustrating it might be seeing an already answered question being posted.

I am not as experienced with RPG Maker coding as you but please don't make assumptions about me or my coding experience based on your opinions about how I want to make this game.
you won't find one because that goes against too many default eventing functions.
he would need a custom plugin specifically designed to work that way.

but for such a custom plugin we are back to needing better descriptions, because the currently given descriptions are not detailed enough.

My honest opinion though?
I think the OP started to program that evented menu without fully understanding all options available through eventing, then made a number of bad choices trying to work around limitations that only exist because he didn't know better, and now has a logic structure that can't work at all but needs a redesign of the internal logic to work.

If he can get a full description up that would either proof otherwise by showing a working logic, or force him to admit that it required a logic redesign.
Sounds more to me like you're the one not understanding what he's asking for, so you're getting angry at RancidPast so to compensate for the fact you don't understand you gotta undermine by assuming they don't have experience simply because they're posting on the forum. I know it makes you feel better to tear someone down in order to process your own incapability to understand what they're asking for, but maybe take a second and understand that this person has made games before and know more than you expect and aren't as stupid as you wish.
It seems that you are a tiny bit perturbed by my recent forum posts. I don't understand why you insist on describing me getting help on the RPG Maker help forum as "demanding things" when I am doing what many forum users are doing and have been doing since these forums have been used.

I have spent many hours working on the code on my own and scrolling through most, if not all, active RPG Maker websites and forums for even vaguely related questions/solutions to my problem. I have always and will always use this forum as the nuclear option if I am genuinely stumped as to how to code something into the game as I know how frustrating it might be seeing an already answered question being posted.

I am not as experienced with RPG Maker coding as you but please don't make assumptions about me or my coding experience based on your opinions about how I want to make this game.

I have no idea about any possible past interactions you two may have had, but in regards to this particular issue, we still need more details. Andar and I have both asked for them, because neither of us can help you with this without a more thorough understanding of exactly what you're trying to do and exactly why the options previously suggested won't work. You weren't initially being frustrating before, just a bit too vague.

Anyways... I'm still waiting for a clearer explanation to see if I'm still able to help, but I can't until I get that. And if Andar's assumption is untrue then providing such details will dual-purpose to disprove it.

Original thread: https://forums.rpgmakerweb.com/threads/solved-press-shift-to-force-close-choice-box.145424/