Open Infiziert90 opened 6 months ago
The behaviour of other programs is more of a cut-off at exactly 500 letters
I don't think many other programs have limitations?
More often a real application would wrap InputText()
to use std::string or their own string type, as shown e.g. https://github.com/ocornut/imgui/blob/master/misc/cpp/imgui_stdlib.h
Are you sure you simply don't want to do that?
Or you want to actually benefit from the clamped pasting?
My case requires a hard limit of 500 characters, so for me clamping is the bigger benefit
User can still paste their text without the text box just staying blank the moment it goes above 500
The ideal fix would requires reworking how calls to STB_TEXTEDIT_INSERTCHARS() are handled:
stb_textedit_paste_internal()
in imstb_textedit.h
.stb_textedit_replace()
in imgui_widgets.cpp which is in theory cannot fail in normal condition (it would fail if user change underlying static buffer between activation and revert).
But it probably means breaking stb_textedit.h API.Another strategy which seems simpler if we perform a clamped call to stb_textedit_paste()
directly in our handler, and only in the case where the buffer is not resizable.
One thing that makes me uneasy about clamping the pasted contents is if you paste from beginning or middle of an existing thing, then your pasted content would be cut off but the cut off is likely to be less visible.
Version/Branch of Dear ImGui:
1.90.2 and before
Back-ends:
Win32 DirectX11
Compiler, OS:
MSVC, Windows 10
Full config/build information:
No response
Details:
Trying to paste a text with < 500 characters into a
InputText(label, string, 500)
will straight up fail, resulting in nothing be added.The behaviour of other programs is more of a cut-off at exactly 500 letters, and i wanted to recreate this. Is it possible to achieve something similar with ImGui?
So:
InputText
Looked over the Callback events, there doesn't seem to be one handled through the InputText directly
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response