Comments (5)
Changing the behavior of the ComboBox's button fixes the issue. Is there a reason why "pressed on click" is not the default option?
bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_PressedOnClick);
from imgui.
You are not well explaining how your sleeping logic works but any mouse press OR release should enforce the next 3 frames to be updated, then you won’t have issues.
from imgui.
The problem might be that ImGUI needs 4 frames to draw an open combo box, not 3.
The sleeping logic is very simple. Instead of using glfwPollEvents();
, I use glfwWaitEventsTimeout(3.0)
. The rest is pretty much the same as in example_glfw_opengl3/main.cpp
. Code to reproduce the issue is here https://gist.github.com/xevgeny/9bc7bc2d4e185cde2b71c52a0270fbb6
From the example above:
Frame 75: click happens
Frame 76: (MOUSE_PRESS)
Frame 77: (MOUSE_RELEASE)
Frame 78: (set popup open = true)
Frame 79: popup opens
Frames 76, 77, and 78 are rendered immediately after the initial mouse click. But nothing triggers frame 79, so the rendering loop waits for 3 seconds as configured.
from imgui.
Then maybe 4 frames is a better wait time for now.
Down the line we should replace the “wait 3-4 frames” by a signal emitted by the lib. I believe our idling system could be made better by noting when a popup is opened or a window is just appearing.
from imgui.
While I am open to discuss the possibility of making combo box start opening on mouse-down, I believe this is not your actual problem here.
Between #7569 and some comments above there is something is miunderstood:
(1) If I change combo-box to starts its opening process on mouse-down rather than mouse-up, in theory it should not change anything with your idling system, because mouse-up is an equally important event than mouse-down.
(2) I ran your repro and things works for me, I do get the combo appearing without delay as soon as I release the mouse button. I wonder if it could be caused by a swap-chain setup requiring an extra glfwSwapBuffers()
to make visible the previous one?
(3) The general logic should look like:
static int run_frames = 2;
if (run_frames > 0)
{
glfwPollEvents();
run_frames--;
}
else
{
glfwWaitEventsTimeout(3.0);
run_frames = 2; // FIXME: No need to increase run_frames if timeout elapsed, how to detect?
}
Tho it is not ideal to set run_frames = 2
when wait events had a timeout.
I believe since the GLFW API doesn't allow it, the easier way to detect this currently is to read GImGui->InputEventsNextEventId
before and after the call, to see if it changed. If it did it means our callbacks have generated events. it's not perfect because e.g. MonitorCallback doesn't immediately registers an event.
(Once we formalize idling we can probably expose a simple IO value to help detect this.)
from imgui.
Related Issues (20)
- Fonts become white rectangles after upgrading to most recent ImGui/SDL3/Vulkan versions HOT 2
- Color too dark custom checkbox color fill HOT 3
- No horizontal scrollbar in a window when calling SetNextWindowContentSize with size larger than the screen HOT 6
- Plugin architecture in imgui(C++)? HOT 4
- Misbehaving GUI when i through libigl to use imgui HOT 2
- DXGI warning with DX11 backend about `DXGI_SWAP_EFFECT_DISCARD` HOT 9
- Transparent issue HOT 3
- ImGui Dockspace not working when viewports are enabled HOT 11
- Tabbar containing dockspace HOT 8
- How to dock a window to the size programmatically wthout taking the whole space HOT 3
- Memory leak when rendering with DX11 in C++ HOT 16
- How to display the same texture with different scale modes? HOT 1
- Shortcut routing for an active item HOT 16
- How to hide border from dockspace ?
- altas is null when use llvm HOT 2
- Extend button hitbox HOT 3
- Can InvisibleButton allow size 0? HOT 5
- Slider automatically setting to random large value on load HOT 2
- How to programmatically trigger Table column sorting? HOT 2
- DX12 example exception HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.