ImGui: Value output of menu item not working correctly

The value output of a menu item in ImGui appears to not do anything. The Bang output does not output a bang, but gets toggled on until you press another menu item. I think this should be what the value outputs.

Currently using a menu item with Channels does not work, since the value output is always just a false boolean.

Which version are you experiencing the bug with?
5.3-preview59

Is there an earlier version where this still works?
not sure

To Reproduce
Steps to reproduce the behavior:

  1. Create an ImGui menu item
  2. Watch the value output as you click the menu item in the UI
  3. Nothing happens, but bang output is now toggled to true

Bonus: connect a channel to it and see that the value is always a false boolean.

You can use the HowTo Menu for an App.vl file from the help patches.

Expected behavior
Value output outputs the active state of the menu item. The bang output outputs a bang (effectively the active state with a tog edge).

Thanks for looking into and potentially fixing.

Have you tried this on the latest preview?
Version 5.3-preview59 seems very outdated.
As I don’t see release number 259 at all, I suppose it’s worth updating first and seeing how things go.

Can confirm

image

image

menu_minimal.vl (9.2 KB)

Thanks for testing. Just downloaded the latest 2023.5.3.-280 and still the same behavior.

Here is a debug version of the menu help patch.

HowTo Menu for an App_Debug.vl (27.5 KB)

1 Like

Just converted to using Channels after all. I have a button and a menu item, which will both trigger the same thing.

Buttons use Channel<Unit>, but Menu items use Channel<Boolean>. That means they are not easily compatible, even though they serve the exact same function: triggering something.

Here is the workaround we had to do to make it work:

Shouldn’t the first Channel of a menu item be the click (Unit) and the IsSelected channel the boolean?

Hi @seltzdesign,

yes, you are right about the first channel, it looks like it should be Channel<Unit>, because it is just a bang.
The second one is really a boolean, because it reflects the state (selected or not).

Thanks!
Anton

1 Like

@seltzdesign
Channels and output pins should be fixed in the upcoming. Thanks for noting this.

@yar
In your screenshot the Bang stays true just because the Menu region is not evaluated anymore after the click on the MenuItem, because the Menu is now closed. This is one of the powers of the VL.ImGui’s Regions (nodes are not executed in the regions that are not Visible), but this leads to these visual “glitches”.

Best,
Anton

1 Like

@robotanton Are you sure it’s just a glitch?

Right, on the click on the MenuItem, Menu closes and everything inside its region is not executed anymore, so no way for a bang to get its false state.

1 Like

That makes sense. But then why call it a bang, if it is effectively the same as what value should be, which is a boolean state. I assume that is because a menu item can also work like a checkbox.

Couldn’t the stop of execution be delayed by 1 frame, so it actually works like a bang? Or is that something that is in the imGui library itself?

@seltzdesign
I can’t agree. It seems that it’s the design, and such a tweak can appear as a terrible mistake in the future.

@robotanton and thank you for explaining this - it’s saved me a lot of time recently when debugging old patches. “Execution while visible” is very important for performance, but we should find a way to make it obvious to users, or write it in big letters to help patches.

@yar: Totally agree, that should be mentioned in the helppatches.

@seltzdesign: Note, the Bang output of the MenuItem is really a bang, it turns true when you click the MenuItem, if you open the Menu again, you’ll see, that the Bang is false again. In contrary to the Is Selected, which reflects the MenuItem’s state (MenuItems in ImGui can be selected). So, if you want to react on the Bang output, do it in the Menu region, if you want to react outside of the region, use the Channel Input.

Best,
Anton