Skip to content
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

how to use textEditCallbackStub? in java? #151

Open
gurachan opened this issue Sep 5, 2020 · 2 comments
Open

how to use textEditCallbackStub? in java? #151

gurachan opened this issue Sep 5, 2020 · 2 comments

Comments

@gurachan
Copy link

gurachan commented Sep 5, 2020

I don't understand this :(

val textEditCallbackStub: InputTextCallback = { data: InputTextCallbackData ->
(data.userData as ExampleAppConsole).inputTextCallback(data)
}
fun inputTextCallback(data: TextEditCallbackData): Boolean {

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

@elect86
Copy link
Collaborator

elect86 commented Dec 11, 2020

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
Copy link
Collaborator

elect86 commented Dec 11, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants