Imgui: Processing events

Created on 22 Jun 2016  路  3Comments  路  Source: ocornut/imgui

Hi,
First of all, you have done a very nice work with ImGui i enjoy it very much since i started playing with it. Thanks for having it open source .
Now about my issue, i've been trying to implement simple things (for starters) and i've came across the fact that there are no function callbacks for event handling . What i mean is that i have a checkbox and everytime i render it to my scene i check also if the value has changed .
To be more specific :

ImGui::Checkbox("blahblah", &checkbox);
if (checkbox == false)
   do_something();
if (checkbox == true)
   do_something_else();

But how can someone implement a function to be called whenever the checkbox is clicked instead of checking it on every "main loop" .

I hope what i meant to say is understood .
Thanks .

Most helpful comment

The entire point of ImGui is to avoid callback/events and resulting state synchronisation requirement.

Note that CheckBox and most functions return true when the value has been modified.

All 3 comments

The entire point of ImGui is to avoid callback/events and resulting state synchronisation requirement.

Note that CheckBox and most functions return true when the value has been modified.

I didn't have that in mind . But reminding me that it returns true only when it's modified helped me with my issue !
Now it's like this
if(ImGui::Checkbox("blahblah", &checkbox) if()... if()...
which does the work .
Thanks for the quick response and the help.
Keep it up .

Ideally your code/data could be structured to avoid any of those if at all, but that's another topic.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GrammarLord picture GrammarLord  路  3Comments

NPatch picture NPatch  路  3Comments

KaungZawHtet picture KaungZawHtet  路  3Comments

bogdaNNNN1 picture bogdaNNNN1  路  3Comments

noche-x picture noche-x  路  3Comments