mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-01 05:10:41 +00:00
Undo / Redo and external editing of input text #1506
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#1506
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
I've an issue with text editing. In my editor, I have my own implementation of undo / redo.
I've managed to disable undo / redo feature in text input by modifying the code (couldn't find a flag)
The issue is that the value returns to its current value after undoing if the text input is active (since the text input stores a cache of the passed values). Is there a way to invalidate the cache while the text input is active?
Thanks
Hello,
It’s an unsolved issue at this point. We can add the flag to disable the undo/reso handling of InputText(), but it will still own the text data while active. I am currently away without a computer but I think you might be able to get away by manipulating the internal activeid during your own undo operation. Try ClearActiveID in imgui_internal.h. But then you will lose your widget focus.
Also browse the issues with the same flag because it has been discussed at least once here.
Ok. Thanks. I also though about maybe calling PushID with the current undo stack size.
That’s an original solution! I hadn’t thought about it, it might work just as well.
I've created a pull request with a new flag to disable undo. #1508
I've merged your PR with tweaks and an additional, however this issue isn't fully resolved as we ought to provide a more obvious way to allow for an external undo stack to be applied on text fields, other than using PushId or ClearActiveId. Preserving cursor/selection may be a bit tricky there.
I ought to clarify: in my previous game engine, CTRL-Z/Y was left to the active input text, and only passed to the engine undo stack based on the
io.WantCaptureKeyboardflag. So there would technically be 2 undo stacks in action but it worked ok.That would work but my undo behaviour is a bit different from what is implemented in the text input. Undoing doesn't delete text letter by letter but instead revert to the state when the text input got focused (this is the behavour in most editors). I do this by tracking if the text is active and then store the current value once it becomes active.
Also, the workaround I proposed above (with PushID) didn't work since once the user inserts a letter, my undo stack size changes causing the text input to lose focus.