imgui icon indicating copy to clipboard operation
imgui copied to clipboard

how to use textEditCallbackStub? in java?

Open Succubussix opened this issue 5 years ago • 2 comments

I don't understand this :(

https://github.com/kotlin-graphics/imgui/blob/78812070f9baaede41a01ba21ffb89d3edd6ea94/imgui-core/src/main/kotlin/imgui/demo/showExampleApp/Console.kt#L219-L223

anyone does have a java version of console.kt .. java decompiler doesn't make any sense :( I want to know how to use that callback thingy in inputText

the decompilation looks like

image

when i read this val textEditCallbackStub: InputTextCallback

i thought its going to be InputTextCallback textEditCallbackStub but theres method stub for InputTextCallback i dont understand xD

Succubussix avatar Sep 05 '20 02:09 Succubussix

Fire up the demo test, then -> widgets -> Text Input -> Filtered Text Input

The following filter is apply

    val filterImGuiLetters: InputTextCallback = { data: InputTextCallbackData ->
        when {
            data.eventChar.i < 256 && data.eventChar in "imgui" -> false
            else -> true
        }
    }

It basically means that if the typed char is no one of imgui then it gets filtered (blocked)

Eg. you can type uiiiiuuuummg

elect86 avatar Dec 11 '20 08:12 elect86

Sorry, I misunderstood what you asked

    var filter = new Function1<InputTextCallbackData, Boolean>() {
        @Override
        public Boolean invoke(InputTextCallbackData inputTextCallbackData) {
            if ("ciao".indexOf(inputTextCallbackData.getEventChar()) != -1)
                return Boolean.FALSE;
            else
                return Boolean.TRUE;
        }
    };
    imgui.inputText("label", "buf", 0, filter, null);

Ps: I can add some overload so you don't have to type null at the end

elect86 avatar Dec 11 '20 08:12 elect86