Jump to content

[MCM] Something I noticed about toggles


3aq

Recommended Posts

As toggles rely on the fact that !toggle is used..

 

I've noticed that it requires the toggle be clicked twice in order for it to switch false to true upon switching to a new page and back. I assume this is the case because it uses the same bool without it changing upon switching to new page. I've tried, and unable to crack it so that bool would reset back to false, but was unsuccessful. That said I am curious if there's a method to make it so there's no need to click twice for the toggle to resume it's usual operation.

 

here's my code, it's the usual (using the example the MCM Faq included)

bool toggleState1 = false

    if(a_option == pt_1a0)
        toggleState1 = !toggleState1
        SetToggleOptionValue(pt_1a0, toggleState1)
            getTxtValues("1a0.txt")
            writeTxtValues_1a()
        endIf

I've tried the following methods with mixed results..

bool toggleState1 = false

    if(option == pt_1a0)
        toggleState1 = !toggleState1
        SetToggleOptionValue(pt_1a0, toggleState1)
            getTxtValues("1a0.txt")
            writeTxtValues_1a()
        toggleState1 = false // what's changed
        endIf

it fixed the toggle so it's untickable after it's been clicked; though the toggle will still commit the get/write lines regardless if it was clicked or not

I've also included a wait --> forcepagereset, but didn't quite like it as it'll freeze the page too long, even at 1 second it felt more like 5.

Edited by 3aq
Link to comment
Share on other sites

You want to be able to click a toggle option, do something and have it automatically revert without the user indicating that they want to toggle it off again? That isn't how the toggles are intended to behave. Toggles are meant to be like an on / off switch. User wants to use that feature, turns it on. User does not want to use that feature, turns it off.

 

At the very least, you can block your stuff from happening when toggleState1 is false by adding a check to make sure that toggleState1 is true.

Link to comment
Share on other sites

As strange as it sounds, yes that's what I wish to do. And I know, it isn't how it's supposed to behave, however that is because I am unable to make it the way it ought to behave.

 

I've encountered three issues with toggle.

 

1. it wouldn't remember what was toggled when I switched pages or exited out of MCM, but it would still remember the bool true/false.

2. my toggling is like a multiple choice check mark one; that being if you check marked a second toggle, by design it should untick the previously clicked toggle. This is something I still am unable to figure out.

3. As it uses bool true/false, and as mentioned in #1, returning to said page i previously toggled, would start the toggle off as true, instead of false, meaning it would require an additional click, now multiply that on all toggles I have and it becomes quite annoying (what with it looking like the initial click did not register with bool remembering its true/false; though this sounds like a small issue, I am sure there will be people who would think it is a bug or glitch if it was implemented.

 

I added that false check so that the bool would reset back to initial state when switching to a page, this is to avoid #3. But that didn't quite work as I intended because I was unable to retoggle it afterwards, though like mentioned before it would still read/write regardless.

 

edit: this is what I mean

note, in the video after the forcepagereset I was unable to retoggle that toggle2.

bool toggleState1 = false
bool toggleState2 = false

Event OnOptionSelect(int a_option)
	if(a_option == pt_1a0)
		toggleState1 = !toggleState1
		SetToggleOptionValue(pt_1a0, toggleState1)
			getCBPValues_1a("1a0.txt")
			writeCBPValues_1a()
		toggleState1 = false
	elseIf(a_option == pt_1a1)
		toggleState2 = !toggleState2
		SetToggleOptionValue(pt_1a1, toggleState2)
			getCBPValues_1a("1a1.txt")
			writeCBPValues_1a()
			Utility.WaitMenuMode(1)
			ForcePageReset()
	elseIf(a_option == pt_1a2)
		acceptWindow = ShowMessage("Load [2] settings?", true, "Yes", "No")
		if(acceptWindow == true)
			getCBPValues_1a("1a2.txt")
			writeCBPValues_1a()
		endIf
	elseIf(a_option == pt_1a3)
		acceptWindow = ShowMessage("Load [3] settings?", true, "Yes", "No")
		if(acceptWindow == true)
			getCBPValues_1a("1a3.txt")
			writeCBPValues_1a()
		endIf

 

the first two option used what I mentioned previously, whereas the final two are the defacto because with the window prompt they do not need the display of toggle to know if it's on or not,

Edited by 3aq
Link to comment
Share on other sites

eureka, I figured out how to reset the bool

 

so the problem initially was because I set toggle state to false within the option select field this would work, but only during the page instance, sadly it would still save the bool state.

so instead, I place the toggle state to false within the page field.. this meant when person clicks on the page it'll always set the bool back to false.

 

now I have to figure out how to make the toggle act like a multiple choice selection field (ie you can only select one of the toggle), this has me stumped.

Link to comment
Share on other sites

For a multiple choice but only one choice, instead of using the toggles you should use the menu option instead.

See: AddMenuOption, OnOptionMenuOpen, OnOptionMenuAccept, and the SetMenuDialog related functions (3 of them)

And on that API page you should also check out the state versions of those functions too.

 

You could even use the text option but then the user would need to click on it repeatedly to cycle through the listing. With the menu option the user just needs to scroll the list that pops up in a smaller menu window.

Link to comment
Share on other sites

Sadly, has to be toggles, I don't think I'd want to scroll through a small listed window. I'd imagine the same goes for the people who would use this. Sadly it's got to be a fill out and move on out. I'll look more into it when I am given the free time, sincere thanks IsharaMeradin; it gave me a lot of ideas to work.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...