lesi123 Posted December 31, 2016 Share Posted December 31, 2016 Is there a way to add a Cancel button to a menu list that just closes the list and ignores any selection changes? I only see Default and Exit buttons. Selecting Default does the expected and loads the default option but selecting Exit (or pressing Escape) forces whichever option is currently selected to load. It causes some values to reset if they were altered after initally selecting an option from the list. Link to comment Share on other sites More sharing options...
lofgren Posted January 1, 2017 Share Posted January 1, 2017 You can just add a cancel option to the menu which did nothing. What I do is usually set the default to whatever the menu opened as, so default becomes the cancel button. Link to comment Share on other sites More sharing options...
lesi123 Posted January 1, 2017 Author Share Posted January 1, 2017 I see, good idea! Thanks! Link to comment Share on other sites More sharing options...
lesi123 Posted January 2, 2017 Author Share Posted January 2, 2017 I messed around with the menus a bit more and found that while the menu list doesn't have a built in Accept/Cancel button, ShowMessage does. Using that, I made some prompts so if you opened the menu and didn't mean to or had second thoughts, you could select any option and just say "No" on the prompt and it would kick you back out to your previous selection with no values changed. Here's a bare bones version of what I did in case anyone wants to know: int PresetsOID_M ; Menu to choose presets string[] PresetsList ; Options on menu to choose a preset int OldPresetIndex ; Integer for current selected preset int PresetsIndex = 0 ; Default option on menu is None event OnConfigInit() ... PresetsList = new string[...] PresetsList[0] = "None " ; space needed after None or menu is blank PresetsList[1] = "Preset 1" PresetsList[2] = "Preset 2" PresetsList[3] = "Preset 3" ... endEvent event OnOptionMenuAccept(int option, int index) if (option == PresetsOID_M) PresetsIndex = index SetMenuOptionValue(PresetsOID_M, PresetsList[PresetsIndex]) ; ---------- DEFAULT BLANK PRESET ---------- if (index == 0) ; None ShowMessage("No preset selected.", false) SetMenuOptionValue(PresetsOID_M, PresetsList[OldPresetIndex]) ; Go back to previous preset selection ; ---------- PRESET 1 ---------- elseif (index == 1) ; Preset 1 if ShowMessage("Are you sure you want to enable Preset 1?", true, "Yes", "No") OldPresetIndex = 1 ; Do stuff ShowMessage("All options adjusted to Preset 1.", false) ForcePageReset() else SetMenuOptionValue(PresetsOID_M, PresetsList[OldPresetIndex]) endif ; ---------- PRESET 2 ---------- elseif (index == 2) ; Preset 2 if ShowMessage("Are you sure you want to enable Preset 2?", true, "Yes", "No") OldPresetIndex = 2 ; Do stuff ShowMessage("All options adjusted to Preset 2.", false) ForcePageReset() else SetMenuOptionValue(PresetsOID_M, PresetsList[OldPresetIndex]) endif ; ---------- PRESET 3 ---------- elseif (index == 3) ; Preset 3 if ShowMessage("Are you sure you want to enable Preset 3?", true, "Yes", "No") OldPresetIndex = 3 ; Do stuff ShowMessage("All options adjusted to Preset 3.", false) ForcePageReset() else SetMenuOptionValue(PresetsOID_M, PresetsList[OldPresetIndex]) endif endif endif EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts