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

Detecting enter pressed on iOS software keyboard. #1868

Closed
mkorman9 opened this issue May 17, 2014 · 13 comments
Closed

Detecting enter pressed on iOS software keyboard. #1868

mkorman9 opened this issue May 17, 2014 · 13 comments
Labels

Comments

@mkorman9
Copy link

@mkorman9 mkorman9 commented May 17, 2014

Pressing "Done" button while RoboVM software keyboard is up should trigger keyDown() or keyTyped() event. Currently most of custom textfields (just like the one from flixel-gdx) don't work because "Done" button just closes virtual keyboard without triggering any event. Invoking keyTyped for '\n' keycode would be a nice idea.

@MobiDevelop
Copy link
Member

@MobiDevelop MobiDevelop commented May 17, 2014

To me, "Done" doesn't mean new line, it means close the keyboard.

@mkorman9
Copy link
Author

@mkorman9 mkorman9 commented May 17, 2014

But it would be good to know about that that press just to unfocus field or commit text change.

@ericnondahl
Copy link
Contributor

@ericnondahl ericnondahl commented Jul 10, 2014

+1. Before updating to the latest libGDX, we were sending \n to the input processor when the keyboard went away so that we could handle the text

@dhex-
Copy link

@dhex- dhex- commented Aug 8, 2014

Same problem here.. I need the user to be able to type "Enter" and to listen to the event.. Done key is useless as it doesn't triggers anything and just closes the keyboard (something easily done with code). When programming In xCode its child's play to change the keyboard layout type but in libgdx it has being a pain in the ass. Please switch the default layout to "enter" key so we can actually do something with that big button.

@BlueRiverInteractive
Copy link
Contributor

@BlueRiverInteractive BlueRiverInteractive commented Sep 3, 2014

I think it would be best to expose the UITextField with a public getter, so everyone can change the attributes of the text field (like keyboard layout) on the fly. Or at least some public methods that allow setting the keyboard type in IOSInput.

IOSInput input = (IOSInput)Gdx.input;
UITextField textField = input.getHiddenTextField();
textField.setKeyboardType(UIKeyboardType.NumberPad);
@dhex-
Copy link

@dhex- dhex- commented Sep 8, 2014

Yes, that would be great, +1

@MobiDevelop
Copy link
Member

@MobiDevelop MobiDevelop commented Sep 8, 2014

This should not be a platform specific offering as Android has the same need. I've been wanting to revamp the on-screen keyboard implementation to expose this functionality through the Input interface.

@mcolombo
Copy link

@mcolombo mcolombo commented Feb 5, 2015

Hi Everyone,

I have a regular text field in my code, and im trying to capture the "done" key in the listener of my textfield for the iOS keyboard but it doesn't work. For android i just compare it to '\n' and it does work.

Does anyone know if this has been implemented for iOS?

Thanks!!

mTextField = new TextField("", styleTextField);
mTextField.setTextFieldListener(new TextFieldListener() {
            @Override
            public void keyTyped(TextField textField, char key) {

                boolean enterKey = key == '\n';
                LogUtil.i("enterKey: " + enterKey);

            }
        });
@Tom-Ski
Copy link
Member

@Tom-Ski Tom-Ski commented Feb 5, 2015

The char 13 is fired as a keyTyped event, also a keyDown event is fired with the key: Keys.ENTER

@mcolombo
Copy link

@mcolombo mcolombo commented Feb 5, 2015

Im sorry, i didn't get it quite well...

the keyDown event is not fired when clicking the 'done' button of the ios keyboard.
And how do i compare it to a 13 char? The keyTyped after hitting the done button is empty...

Thanks in advance Tom!

@Tom-Ski
Copy link
Member

@Tom-Ski Tom-Ski commented Feb 5, 2015

This is where these events are fired https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSInput.java#L415

You should be able to do if (key == '13') (done/enter has been pressed)

@mcolombo
Copy link

@mcolombo mcolombo commented Feb 6, 2015

Oh perfect! It worked!

thank you very much!

@dhex-
Copy link

@dhex- dhex- commented Feb 6, 2015

Thank you Tom-Ski for finally merging the thing, never got the chanse to thank you

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

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.