`onshown` for Parents
Opened this issue · 7 comments
I have a separate nk_label in its own window I use for a none scrolling title to my menu that is being very difficult to re-implement when switching from regular nuklear to nuklear_console. I would have hoped I could have circumvented all of this just by setting the currentPage value each time I click a parent and enter a sub menu but as soon as you set an onclick for a button it will no longer navigate to children defined underneath it. So there is no way to send an event when you click a button that has sub elements.
Sadly the active widget index is useless in this case as I am not looking to change the title until I enter a submenu and the active widget only reports the parents index within the root. ie it only updates while I'm in the root menu when it should read "Paused" but there is currently no way to tell you have left the root and entered a sub.
Checkbox could also use the option to have onclick events, basically anything that can be clicked should have this option as it's not uncommon that if you click something you may want more options then just the basics.
Things like this sometimes require it
int ammoRechargeStation = enhanced_features0 & kFeatures0_AmmoRechargeStation;
if (nk_checkbox_label(ctx, "AmmoRechargeStation", &ammoRechargeStation)) { enhanced_features0 ^= kFeatures0_AmmoRechargeStation; }
it would take me a lot of jumping through hoops to do the same with nuklear_console
There is onchange
events for when the value changes. I don't think that it has been applied to all widgets yet. Could use some help there.
Are you looking to have an event for when a widget's parent is shown? Maybe something that would call a shown
event called from nk_console_set_active_parent()
?
void widgetShown(nk_console* console) {
nk_console_show_message(console, "OH MY GAWD!");
}
nk_console_set_shown(myWidget, widgetShown);
Are you looking to have an event for when a widget's parent is shown? Maybe something that would call a
shown
event called fromnk_console_set_active_parent()
?void widgetShown(nk_console* console) { nk_console_show_message(console, "OH MY GAWD!"); } nk_console_set_shown(myWidget, widgetShown);
Not when a parent is shown but when you enter a child what child you entered. That is probably the best way to phrase it. ie if I'm on the root with "Resume" , "Options", "Reset" and "Quit". If I select "Options" (Widget index 1) currently I can only tell I was on index 1 last not weather I have selected it and entered it's child list. A call to say you entered a child or when you exit a child back to the parent.
The idea being that the title on root says "Paused" but changes to "Options" while inside options and returning to "Paused" when I return to the root.
I could possible achieve this with just checking the index but only if the index error out to -1 when in a subindex as atm checking the index by passing in the parent or the child widget both return the index in the parent only.
nk_console_get_active_widget(console)
and nk_console_get_active_widget(options)
both return an index value while navigating console
but as soon as I enter options
it stops updating.
I would have assumed I should have been able to use nk_console_get_active_widget(console)
to get the root index and nk_console_get_active_widget(options)
to get the index while I'm in said child but it also returns only the index in relation to console
ie it never changes while in options
even when you are calling the active check against options.
This still would not be ideal though as I'd have to do a lot of if checks just to verify what menu layer I am in.
There is
onchange
events for when the value changes. I don't think that it has been applied to all widgets yet. Could use some help there.
I overlooked the onchange
this does work for checkboxes so I can do the bit flip that way.
Having a new event for when a parent becomes active could be an option too. Will do some thinking on this. Don't want to bloat the struct, but it could be a thing if it's proven helpful.
What should we call this event? It's when the parent is switched to...
NK_CONSOLE_EVENT_PARENT_SHOWN
NK_CONSOLE_EVENT_PARENT_ACTIVE
NK_CONSOLE_EVENT_DISPLAYED
NK_CONSOLE_EVENT_SHOWN