TCastleEdit on Android - how to show keyboard?

I am testing TCastleEdit on Android. I created the following app:

procedure ApplicationInitialize;
begin
  Background := TCastleRectangleControl.Create(Application);
  Background.Color := White;
  Background.FullSize := true;
  Window.Controls.InsertFront(Background);

  Edit1 := TCastleEdit.Create(Application);
  Edit1.Text := 'Hello world';
  Edit1.Width:=200;
  Edit1.Anchor(hpMiddle);
  Edit1.Anchor(vpTop, -50);
  Background.InsertFront(Edit1);
end;

So it displays nicely edit control on Android. The cursor is flashing. But when I click on the edit then there is no keyboard popup.

Do you have any suggestions how to use TCastleEdit on Android? How to enter text into it? How to correct the text (how to use backspace, delete, maybe copy/paste).

We simply didn’t implement yet integration with on-screen keyboard on Android and iOS. While it is critical to make TCastleEdit sensible on mobile, there just wasn’t time to finish it earlier :), and in many games it turned out to not be needed.

Let me know how critical it is to you. I’ll try to make it soon.

Michalis,

I am going to use CGE for several small one-level/board games and for some funny apps working with sound.
So the existing functionality of CGE is OK for these projects.

But I also need to create a port for Android of existing Windows app written Delphi and having 130+ forms.

The initial version on Android should have about 20 forms because it will make only a small part of all functions.

Thus I am in process of deciding which framework will better suit my needs for this project?

I don’t like the way it could be done with FireMonkeye. I want to move the whole Windows project to Lazarus.
What I really like in CGE is that it’s really cross platform. But I need controls like TEdit and TMemo working on Android.
Technically in CGE I may create own virtual keyboard based on, for example, TCastleRectangleControl. And they call this keyboard OnClich on every TCastleEdit for example.

For Lazarus there are several attempts like:
https://wiki.lazarus.freepascal.org/Custom_Drawn_Interface/Android
https://wiki.lazarus.freepascal.org/Android_Interface/OpenGL_ES_GUI
https://wiki.lazarus.freepascal.org/Android_Interface/Native_Android_GUI
But these approaches create more Android-depended code. For example, I could not build such app for iOS.

There are also Flutter, React Native. But I am a really Pascal-man :slight_smile:

So support of keyboard for TCastleEdit is not urgent and it not quite critical. But could you explain how are you going to implement it in short phrases? Normal CGE app runs in full-screen. So do you think it’s possible to call native Android keyboard on top of it? Or should we declare the keyboard like on the page and then CGE app will be shown not in full-screen but with keyboard under it?
https://wiki.lazarus.freepascal.org/Android_Interface/Native_Android_GUI

    <activity
         android:configChanges="orientation|keyboardHidden"

or

<activity android:name="com.your.package.ActivityName"
          android:windowSoftInputMode="stateHidden"  />

so instead of hidden we have to force showing the keyboard.

We already have possibility to toggle keyboard visibility at runtime on Android, set TCastleEdit.AutoOnScreenKeyboard and then keyboard is shown/hidden from TCastleEdit.SetFocused. You can test it, as far as I recall there was no problem with toggling it at runtime from CGE fullscreen apps.

By default AutoOnScreenKeyboard is off, as

  1. the keyboard doesn’t do anything (doesn’t communicate input to TCastleEdit),

  2. and also it’s not ideal — what happens in case of multiple TCastleEdit (or similar fuutre controls like TCastleMemo).

These 2 things are waiting to be fixed :slight_smile:

I tried to set:
Edit1.AutoOnScreenKeyboard:=true;

It works fine by showing the native Android keyboard at the bottom of the screen. But it does noticing :slight_smile: At least I understand that technically it’s possible to make the keyboard working.