iOS Bug: Button Shortcut not working (Example inside)

Button::addShortcut works on Mac, but not on iOS. Please see the attached example. Focus the text editor, then press the Return key (on iOS using the on-screen keyboard). When you do it on the Mac, the OK button gets clicked. On iOS, nothing happens.

The reason seems to be that it relies on Button::CallbackHelper::keyStateChanged to be called. NSViewComponentPeer does that, whereas UIViewComponentPeer doesn’t. But I didn’t look into the internals for too long.

It would be great to get this fixed :slight_smile: I’m on JUCE commit ccbcc41b.

ReturnKeyTest.zip (5.3 KB)

1 Like

Bump

I don’t think this is a bug. I can’t think of any iOS apps in which pressing the return key on the soft keyboard emulates a button press and in the example that you provided the expected behaviour would be that the return key adds a newline to the editor. There is no key handling code in the iOS ComponentPeer and I’m not sure it’s something we’d want to add.

Thanks for looking into this!

in the example that you provided the expected behaviour would be that the return key adds a newline to the editor.

I would like to create an Ok/Cancel dialog with a text input, and the user should be able to confirm the dialog from the on-screen keyboard, as usual on iOS. I should have made the text field smaller (single-line) to make it more clear.

Meanwhile I found a way to do it, using TextEditor::Listener::textEditorReturnKeyPressed.

Would it be possible to customize the on-screen keyboard’s UIReturnKeyType to something like UIReturnKeyDone? I understand that that’s somewhat platform-specific, but so is TextInputTarget::VirtualKeyboardType.

This is actually a very common option for iOS. For example check out the Remote App that controls your AppleTV. There is a Go/Enter button that allows you to Enter data.

That feels a bit too platform-specific to live in the TextEditor class. The VirtualKeyboardType is at least used on both iOS and Android but I can’t see an equivalent to UIReturnKeyType on Android.