PDA

View Full Version : Doing something wrong with menu code, leaving blank starting entry.



StoryWeaver
March 19th, 2020, 05:00
Hey,

For some of the menu items I'm adding, an extra blank entry is added as the first one.
I'm sure it's a simple mistake somewhere in how I'm setting the menu up.

Here is some sample code:


OptionsManager.registerOption2("IM_BG", false, "option_header_5eenhancher_window_resizing", "option_backgrounds", "option_entry_cycler",
{ labels = "default|larger", values = "option_default|option_larger", default = "option_default" })

What I want are two entries in the menu, with the entry named "default" in this case being the first one and appearing as default. Without a blank entry being added to the rotation.
For some other entries I have several options, where I'm also getting an extra blank entry at the start.

What am I getting wrong here?

Trenloe
March 19th, 2020, 10:49
Cycler controls have a default value - which is usually when the underlying field is actually empty. So you don't specify a values or labels entry for the default option, just the string to display on the button in the default entry when the underlying field is blank.

Try this:


OptionsManager.registerOption2("IM_BG", false, "option_header_5eenhancher_window_resizing", "option_backgrounds", "option_entry_cycler",
{ labels = "larger", values = "option_larger", default = "default" })

StoryWeaver
March 19th, 2020, 21:09
Thanks for the response Trenloe.

That makes sense.

I tried replacing the code with your fix and it left me with a blank field and a "larger" field, to select from.
After I've been trying all kinds of combinations of omitting, switching entries, adding or excluding additional options such as baselabel, baseval. All have resulted in the same as above or an additional blank field.

The only time I don't get an extra empty field is if it's a simple on | off switch.
Such as:


OptionsManager.registerOption2("CE_HCW", false, "option_header_5eenhancer", "option_actor_health_widget_conditions", "option_entry_cycler",
{ labels = "option_val_on", values = "on", baselabel = "option_val_off", baseval = "off", default = "on" })

And here the label and value entries switch places, yet in both cases the label displayed is correct. Rather confusing as it doesn't seem consistent. Also this has left me wondering if "on" and "off" are some kind of keywords. As when switched for other custom values in the labels and values an extra blank field shows up.