Comments (11)
👍 I have exactly the same problem trying to implement a console.
from imgui.
I'll have to think how to handle that. To handle cursor-position based completion (and cursor preserving history) your code will need to have access to data such as cursor position, selection.
Once InputText is able to expose those data into a small structure and read them back if modified then it could just call a callback and you can do what you want within it. So maybe the system doesn't need to be created with keystroke in mind in particular.
Note that if you don't need the cursor position you could probably get away with just using a function that can tell you if the current widget has focus, and then run your code after. This function is currently missing in ImGui but trivial to implement so I could add that as a first step.
What do you mean by "(Would be nice to have an ImGuiKey_Tab for this as well,)" ?
from imgui.
What do you mean by "(Would be nice to have an ImGuiKey_Tab for this as well,)" ?
Oh, I mean currently Tab is treated as a "text" character and wouldn't be intercepted by the code in InputText. But I suppose the "text input" loop could check for '\t' as well.
from imgui.
Yes, however this is implemented it would have to work for TAB obviously.
from imgui.
I am now working on implementing a nice console with those example as a test ground for adding the missing features.
from imgui.
Yay!
On Wed, Oct 29, 2014 at 5:19 AM, omar [email protected] wrote:
I am now working on implementing a nice console with those example as a
test ground for adding the missing features.—
Reply to this email directly or view it on GitHub
#68 (comment).
from imgui.
Not much progress on the actual requests (history/completion) but I have implemented a basic console (that doesn't have those features yet!). However toward doing this I already made a few others small changes/additions to the library.
Stay tuned!
edit the example in included as part of the demo window.
from imgui.
Coool! :D
from imgui.
I have added the callback options now.
( It was messier than initially expected because the text input manipulates wchar internally and I wanted to provide UTF-8 to the user because that is what the user provides as input. With variable-size characters in UTF-8 have to convert thing like cursor-pos and selection range from character-to-byte and vice-versa, along with the text itself, and InputText() has a bunch of hoops already. I may want to clean that mess in the future. )
I have implemented a demo of completion in the console.
If you TAB It lists commands, input "h" and TAB it replace with "HELP" (the example replace casing in what you typed). If there are multiple matches it displays the matches and complete as much as possible, so "C" become "CL".
I have not implemented history in the demo yet but the callback should be there (untested).
The console demo app is 170 lines which is starting to be a little too much but that is due to the fancy completion scheme. It might be time to move sample code to a separate location? hmm?
from imgui.
Closing this now. Will add a sample code for History using up/down later on but the feature is available.
from imgui.
fyi - the Console example now handles history with Up/Down arrows along with a command "History.
from imgui.
Related Issues (20)
- Drag drop does not work with Child HOT 6
- When ImGuiChildFlags_AlwaysUseWindowPadding is enabled, the left and right padding widths of the Child are different, but the Parent window is the same HOT 5
- No scrolling region or selectable items inside Child HOT 3
- Can't write in any field. (1.90.5-docking with SDL3) HOT 1
- `BeginGroup`/`EndGroup` with table inside reports incorrect item size
- Delay in Combo Popup Opening with glfwWaitEventsTimeout HOT 4
- Where's the binaries? HOT 4
- Mouse scrolling not working HOT 6
- Imgui community HOT 1
- Rendering vertices with the D3DPT_LINESTRIP type. HOT 1
- Can't access some stuff from imgui.h HOT 1
- Suggestion: Consider Adding Title Bar Text to Popups HOT 2
- SDL3 Multi-Viewports not creating windows when main window is hidden
- Recommended way to expand / collapse tree nodes with keyboard shortcuts? HOT 3
- VuIkan: invalid Dynamic Rendering functions from the Instance-level loader HOT 3
- Text Bottom Padding Bug HOT 1
- Power savings & hardware usage HOT 3
- Add RGFW backend implementation HOT 2
- Text wrapping: how does it work? HOT 1
- ImDrawList rects aren't perfect HOT 6
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.