-
Notifications
You must be signed in to change notification settings - Fork 186
InputText, InputTextMultiline, InputFloat, InputInt #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I will pull it locally to see what may be the cause if these issues. If something does not work with imgui demo window it is either a bug in imgui C++ implementation or a problem with the inputs processing (so PySDL/GLFW integration). I will review the #14 PySLD2 PR soon and then compare results between different integrations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Text input functions require some changes but the float/input functions seem correct.
imgui/core.pyx
Outdated
# return changed, bytes_text.decode('utf-8') | ||
|
||
cdef bytes bytes_text = _bytes(value) | ||
cdef char inout_text[2056] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This inout_text
buffer size should be a function argument. This will require dynamic allocation and proper string type handling via Python/C API.
imgui/core.pyx
Outdated
|
||
cdef bytes bytes_text = _bytes(value) | ||
cdef char inout_text[2056] | ||
strcpy(inout_text, bytes_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be simply strcpy(inout_text, _bytes(value))
. The local bytes_text
variable is redundant (see comments below).
imgui/core.pyx
Outdated
_bytes(label), inout_text, sizeof(inout_text), flags, NULL, NULL | ||
) | ||
|
||
return changed, bytes_text.decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to return a buffer, so inout_text
instead of bytes_text
. Also I'm not sure about this decode('utf-8')
this introduces a compatibility issue in Python2.7.
In Python2.7 this function will accept str
as value
but returns unicode
. We need to either force str
somehow. Maybe right now for consistency we need some opposite implementation of the _bytes()
function. Maybe _from_bytes()
?
imgui/core.pyx
Outdated
text_val = 'Please, type the coefficient here.' | ||
imgui.begin("Example: text input") | ||
changed, text_val = imgui.input_text('Amount:', text_val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label will be displayed on right so semicolon looks weird in the example.
You can either use hidden label with ##
prefix:
changed, text_val = imgui.input_text('##Amount:', text_val)
or simply use imgui.same_line()
.
imgui/core.pyx
Outdated
) | ||
""" | ||
|
||
# return changed, bytes_text.decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary comment
doc/source/guide/inputtext-flags.rst
Outdated
.. _guide-inputtext-flags: | ||
|
||
Using input text flags | ||
================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the underline same width as the title. Otherwise Sphinx will generate warnings.
float width=0, | ||
float height=0, | ||
cimgui.ImGuiInputTextFlags flags=0 | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as for input_text()
function apply also here.
I did run this in my local environment and here is my feedback:
3., 4. and 5. can be handled in separate issues/PRs. |
I have found the reason for problem 3. It is a timing issue and both PySDL2 and GLFW3 do not measure time deltas properly. Will be very easy to fix. |
Hey :), All those PR got me confused and i won't be surprised if i messed the branches again. Cheers, |
Changes Unknown when pulling 5c221ac on supudo:InputBoxes into ** on swistakm:master**. |
This branch is fine. You did not mess anything here :). The There are just some two issues with |
Changes Unknown when pulling a89139f on supudo:InputBoxes into ** on swistakm:master**. |
Hey, Fixed and passed :) Cheers, |
Hey :),
This one contains the InputXYZ functions. There's one not-so-minor issue, which also is present in the ImGui demo window.
For InputText if the buffer size is not specified as something big like 1024 or bigger it will take the passed value and use it as a limit - so if you pass "Text" it will display text but will also put limit of 4 chars on the input. No idea why this happens, so i've put a 2056 char array as limit for now. Same applies for the InputTextMultiline function.
Another issue with the inputs i noticed is that it works too fast, meaning if i type "A" it's ok, but if i do backspace (delete) and enter (new lines) it deletes multiple characters/words or puts lots of new lines. Same behaviour exists in the ImGui demo window by the way, so i think it might be something either in the implementation or in Cython itself.
Will keep digging to see if i can fix it.
P.S. Same type of issues i noticed with scrolling - if you have a big height window and you scroll with the mouse for ex., it always goes either at the top or at the bottom, you can't position it in the middle. Same issues with the combo lists.
P.P.S. All of those are observed on Python 3.5 with the PySDL implementation, so they might not be present in Python 2.X.
Cheers,
S.