Comments (7)
Who is supposed to set io.WantCaptureKeyboard?
Active text input fields, or via ImGui::SetNextFrameWantCaptureKeyboard(true)
. See Demo > Inputs & Focus > WantCapture override.
from imgui.
Yes, that does it and the right place to put it seems to be
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows))
{
ImGui::SetNextFrameWantCaptureKeyboard(true); // << GOOD LOCATION
if (ImGui::IsKeyChordPressed(ImGuiKey_Space | ImGuiMod_Ctrl))
{
// DO NOT PUT IT HERE!
//
// handle keypress
I looked at InputText
and it seems to use a different system (g.ActiveId
), but I think it is beyond the scope of the issue to understand the difference.
Instead I wanted to ask: imagine a child of the above widget is already handling key events (via the same method or like InputText
): how to I filter this case to only capture residual key events? In a more traditional widget system, when an event is accepted
it stops being propagated. Is it possible here?
from imgui.
Don't know if I should open a new issue or continue here.
This is about selecting widgets using TAB
.
I see it is already enable for InputText
and this can be controlled via PushTabStop
.
But for TabItems, is it possible to cycle through the selected tab using TAB
?
from imgui.
Instead I wanted to ask: imagine a child of the above widget is already handling key events (via the same method or like InputText): how to I filter this case to only capture residual key events? In a more traditional widget system, when an event is accepted it stops being propagated. Is it possible here?
The current mechanism which I am pushing for but isn't fully documented is a mix of setting and testing for key ownership and/or registering shortcut routes (the later register key ownership when the mods matches).
If you call Shortcut(ImGuiKey_Space | ImGuiMod_Ctrl)
in both parent and child location, you'll find that only the deep most one gets the shortcut. It's a rather complex multi-faceted problem that doesn't have a single answer, but if you want to detail your use case I may be able to suggest a direction.
Unfortunately this mechanism doesn't necessarily set io.WantCaptureKeyboard
for the "background" application to use.
Technically your key handler could also check if a key is owned (if (ImGui::GetKeyOwner(ImGuiKey_XXXX) == ImGuiKeyOwner_None
) and use that as a secondary filter to not pass keys to background application. However this would only work for code that is setting key ownership correctly. Some randomly placed IsKeyPressed(ImGuiKey_XXX)
unless SetKeyOwner()
is also called, which standard widgets do, and which e.g. Shortcut()
will do indirectly do.
This is about selecting widgets using TAB.
I see it is already enable for InputText and this can be controlled via PushTabStop.
But for TabItems, is it possible to cycle through the selected tab using TAB?
I don't understand what you are saying here. It looks like a different topic, is it? If it a different topic please open a new issue and provide more details.
from imgui.
Thank you for the explanation. I was not aware of Shortcut
, nor KeyOwner
.
I see them in imgui_internal.h
. I will look to see if I understand them, but I fear that until they land in the Demo I will have a hard time.
For the time being, I have rearranged a bit the hierarchy to remove the ambiguity, but I will keep an eye on further developments.
from imgui.
Sorry I meant to add there is a public branch with a bunch of demos for those functions as well. I canβt merge the demos before i move those public to api realm, but i think most are pretty stable now. My main bother is that outside of just using Shortcut(), the system can be a bit confusing
from imgui.
The demos are here:
master...features/demo_input_owner_and_routing
from imgui.
Related Issues (20)
- Text wrapping: how does it work? HOT 1
- ImDrawList rects aren't perfect HOT 7
- Running ImGui app on Arm Processor (Allwinner H3 with mali 400 -> orangepi one) HOT 1
- Can no longer use ctrl shortcuts in InputText's as of v1.90.6 HOT 4
- ImGui::BeginTooltip() should allow specifying override HOT 4
- No Hover Flags in ImGui::IsAnyItemHovered() HOT 4
- Keeping combo open after clicking selectable
- Stretch table to window scrollable size
- TitleBarRect does not contain FramePadding. This will cause the window to not move correctly after ConfigWindowsMoveFromTitleBarOnly is enabled.
- Small window flickering when move out the edge of main window. HOT 5
- Can't select only 1 input when inputs are slightly close to each other HOT 12
- Unresolved external symbol, all ImGui CPP Files are included HOT 3
- Jumping the user to a different part of the GUI HOT 3
- Mouse resize child window HOT 1
- Changing hIcon and hIconSm are not changing to custom icon HOT 1
- io.WantCaptureMouse doesn't work for scrollwheel HOT 3
- How to use ImGui rounding style for ImGui::MenuItems? HOT 2
- Scale to window maintaining aspect ratio, but Viewport won't center HOT 2
- Please help me to clarify the concepts of some specific terms HOT 2
- WebGPU ImGui::Image not accepts different texture formats HOT 3
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.