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

Unable to use cc.EditBox on iOS 13.2.2 with CoreText issue #20334

Closed
0xJimmyBeh opened this issue Nov 14, 2019 · 14 comments
Closed

Unable to use cc.EditBox on iOS 13.2.2 with CoreText issue #20334

0xJimmyBeh opened this issue Nov 14, 2019 · 14 comments

Comments

@0xJimmyBeh
Copy link

  • cocos2d-x version: latest github v3 branch
  • devices test on: iphone xr iOS 13.2.2
  • developing environments
    • Xcode version: 11.2

Steps to Reproduce:

  1. Using js-tests for iOS
  2. Extensions Test -> EditBox Test
  3. Touch any editbox for input will hang and no keyboard popup

Issue log on Xcode
CoreText note: Client requested name ".SFUI-Regular", it will get TimesNewRomanPSMT rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[UIFont systemFontOfSize:].

@minggo
Copy link
Contributor

minggo commented Nov 15, 2019

I tested on iPhone11, can pop up keyboard, but can not close the keyboard, which is fixed in #20336.

@minggo minggo closed this as completed Nov 15, 2019
@0xJimmyBeh
Copy link
Author

sorry, i found this issue is caused by the static library libcocos2d iOS.a generated with cocos2d_libs.xcodeproj.

i linked cocos2d_libs.xcodeproj in the project, the editbox is working but can not close the keyboard as stated, the fixed is working.

between, if i set the editbox return type to cc.KEYBOARD_RETURNTYPE_DONE or either one of below, all will just give a newline but not closing the keyboard, is this the right response as DONE should consider finish typing?

            cc.KEYBOARD_RETURNTYPE_DEFAULT,
            cc.KEYBOARD_RETURNTYPE_DONE,
            cc.KEYBOARD_RETURNTYPE_SEND,
            cc.KEYBOARD_RETURNTYPE_SEARCH,
            cc.KEYBOARD_RETURNTYPE_GO,

no cc.KEYBOARD_RETURNTYPE_NEXT = 5; in script/extension/jsb_cocos2d_extension.js and script/ccui/jsb_cocos2d_ui.js

but UIEditBox.h do have the enum

        enum class KeyboardReturnType
        {
            DEFAULT,
            DONE,
            SEND,
            SEARCH,
            GO,
            NEXT
        };

@minggo
Copy link
Contributor

minggo commented Nov 15, 2019

As i remembered, when you use English keyboard, there is not way to add a new line. So use Done key to add a new line.

@0xJimmyBeh
Copy link
Author

0xJimmyBeh commented Nov 15, 2019

yes, there is no way to add a new line with iOS keyboard.
by default, the KeyboardReturnType key will labeled as "return" which should give new line.

from what i understand :

RETURN -> give new line
DONE -> finish typing and close keyboard
SEND -> send the email / chat message and close keyboard
SEARCH -> trigger the search button next to the editbox
GO -> similar to browser, go to the URL
NEXT -> go to next editbox of a form

but in current implementation, all the KeyboardReturnType giving the same new line with just different label which give not related response to the label.

so there is no way to close the keyboard except touching outside the EditBox

@minggo
Copy link
Contributor

minggo commented Nov 15, 2019

SEARCH -> trigger the search button next to the editbox
GO -> similar to browser, go to the URL
NEXT -> go to next editbox of a form

Engine doesn't know if there is a next editbox or not.

@0xJimmyBeh
Copy link
Author

but why there is this enum in CCUIEditBox.h

enum class EditBoxEndAction {
            UNKNOWN,
            TAB_TO_NEXT,
            TAB_TO_PREVIOUS,
            RETURN
        };

and implementation of TAB_TO_NEXT in CCUIEditBoxIOS.mm if engine doesn't know?

- (cocos2d::ui::EditBoxDelegate::EditBoxEndAction)getEndAction
{
    cocos2d::ui::EditBoxDelegate::EditBoxEndAction action = cocos2d::ui::EditBoxDelegate::EditBoxEndAction::UNKNOWN;
    if (self.returnPressed) {
        if (self.keyboardReturnType == cocos2d::ui::EditBox::KeyboardReturnType::NEXT) {
            action = cocos2d::ui::EditBoxDelegate::EditBoxEndAction::TAB_TO_NEXT;
        } else if (self.keyboardReturnType == cocos2d::ui::EditBox::KeyboardReturnType::GO ||
                   self.keyboardReturnType == cocos2d::ui::EditBox::KeyboardReturnType::SEND ||
                   self.keyboardReturnType == cocos2d::ui::EditBox::KeyboardReturnType::SEARCH) {
            action = cocos2d::ui::EditBoxDelegate::EditBoxEndAction::RETURN;
        }
    }
    return action;
}

if it is engine limit without passing reference of next editbox, how about make

  1. cc.KEYBOARD_RETURNTYPE_DONE -> close keyboard
  2. cc.KEYBOARD_RETURNTYPE_DEFAULT or other -> new line

@0xJimmyBeh
Copy link
Author

there is a hide keyboard key on iPad keyboard but not iPhone keyboard layout.

@minggo
Copy link
Contributor

minggo commented Nov 15, 2019

there is a hide keyboard key on iPad keyboard but not iPhone keyboard layout.

Sorry, i don't know what did you mean. And what's the problem?

@0xJimmyBeh
Copy link
Author

there is a hide keyboard key on iPad keyboard but not iPhone keyboard layout.

Sorry, i don't know what did you mean. And what's the problem?

the default keyboard from iOS at iPhone and iPad is different

ipad layout, the highlighted key can hide keyboard but is not found in iPhone keyboard layout
ipad keyboard

so my suggestion above of cc.KEYBOARD_RETURNTYPE_DONE -> to hide keyboard is useful for iPhone only

@minggo
Copy link
Contributor

minggo commented Nov 15, 2019

You can click the area outside of keyboard to close keyboard.

@0xJimmyBeh
Copy link
Author

You can click the area outside of keyboard to close keyboard.

yeah i know, i just hope there is other way to close keyboard in case if the whole screen is EditBox and make the different ReturnType useful.

@minggo
Copy link
Contributor

minggo commented Nov 15, 2019

Yep, i think you are right. #20341 fixed it.

@0xJimmyBeh
Copy link
Author

Yep, i think you are right. #20341 fixed it.

i tried the fixed and is working on the js-test when set ReturnType to DONE.
thanks, thats quick fixed!

between, which is the best way to generate prebuilt library of cocos2d.a and jscocos2d.a?

is it just follow the cmake guide and compile with Cocos2d-x.xcodeproj?

### Generate iOS Project

```sh
cd cocos2d-x
mkdir ios-build && cd ios-build
cmake .. -GXcode -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake
open Cocos2d-x.xcodeproj

@0xJimmyBeh
Copy link
Author

Prebuilt Issue

  1. Cmake
    i try using cmake with above code to generate Cocos2d-x.xcodeproj and compile the library which generate libcocos2d.a and libjscocos2d.a. Then i link these 2 files to my Xcode project but get compile error Undefined symbols for architecture arm64 for more than 100 function related to cocos2dx

  2. using cocos2d_libs.xcodeproj in build and cocos2d_js_bindings.xcodeproj in scripting
    generated libcocos2d.a and libjscocos2d.a and link to my Xcode project, everything compile just fine and app can be run, but unable to use cc.EditBox issue as stated above.

  3. End up i have to link cocos2d_libs.xcodeproj and cocos2d_js_bindings.xcodeproj to my Xcode project, everything works just fine but with longer compile time.

I used to generate prebuilt with cocos console but that function was removed after v3.17.1, i still using v3.17

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