@@ -2,6 +2,7 @@ package imgui.imgui
22
33import gli_.has
44import gli_.hasnt
5+ import glm_.c
56import glm_.f
67import glm_.func.common.max
78import glm_.func.common.min
@@ -1430,8 +1431,19 @@ interface imgui_internal {
14301431 var clearActiveId = false
14311432
14321433 var selectAll = g.activeId != id && flags has Itf .AutoSelectAll
1433- if (focusRequested || userClicked || userScrolled) {
1434- if (g.activeId != id) {
1434+ // println(g.imeLastKey)
1435+ if (focusRequested || userClicked || userScrolled || g.imeLastKey != 0 ) {
1436+ if (g.activeId != id || g.imeLastKey != 0 ) {
1437+ // JVM, put char if no more in ime mode and last key is valid
1438+ // println("${g.imeInProgress}, ${g.imeLastKey}")
1439+ if (! g.imeInProgress && g.imeLastKey != 0 ) {
1440+ for (i in 0 until buf.size)
1441+ if (buf[i] == NUL ) {
1442+ buf[i] = g.imeLastKey.c
1443+ break
1444+ }
1445+ g.imeLastKey = 0
1446+ }
14351447 /* Start edition
14361448 Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
14371449 From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode) */
@@ -1531,7 +1543,8 @@ interface imgui_internal {
15311543 is Alt+Ctrl - to input certain characters. */
15321544 if (! (IO .keyCtrl && ! IO .keyAlt) && isEditable)
15331545 IO .inputCharacters.filter { it != NUL }.map {
1534- withChar { c -> // Insert character if they pass filtering
1546+ withChar { c ->
1547+ // Insert character if they pass filtering
15351548 if (inputTextFilterCharacter(c.apply { set(it) }, flags/* , callback, user_data*/ ))
15361549 editState.onKeyPressed(c().i)
15371550 }
@@ -1766,7 +1779,7 @@ interface imgui_internal {
17661779 }
17671780 // Copy back to user buffer
17681781 if (isEditable && ! Arrays .equals(editState.tempTextBuffer, buf)) {
1769- repeat( buf.size) { buf[it ] = editState.tempTextBuffer[it] }
1782+ for (i in 0 until buf.size) buf[i ] = editState.tempTextBuffer[i]
17701783 valueChanged = true
17711784 }
17721785 }
@@ -1914,7 +1927,7 @@ interface imgui_internal {
19141927 }
19151928
19161929 drawWindow.drawList.addText(g.font, g.fontSize, renderPos - renderScroll, Col .Text .u32, bufDisplay,
1917- editState.curLenA, 0f , if ( isMultiline) null else clipRect )
1930+ editState.curLenA, 0f , clipRect. takeIf { isMultiline } )
19181931
19191932 // Draw blinking cursor
19201933 val cursorIsVisible = ! IO .optCursorBlink || g.inputTextState.cursorAnim <= 0f || glm.mod(g.inputTextState.cursorAnim, 1.2f ) <= 0.8f
0 commit comments