Maybe someone already notice that:

Maybe someone already notice that:

When using the keyboard with Android we should scroll the screen so the text box can be editable. Well, with Delphi Tokyo Update 1 and using a QHD smartphone (LG G6), ie., that will not work.

I opened the ScrollableForm demo and it also fail, so I check and figure out that CalcContentBoundsProc() function uses the global ClientHeight and that var returns 0 as value.

I changed to Screen.Height and even not perfect it works now, because i still need to use the finger to get more space.

Any advice on that?

Comments

  1. H Visli Thanks, but I was unable to make it work. I already had the KatriFree, did step by step but it won't work as it should. I did not got if it will need the old approach of using TVertScrollBox or not. So I put that code into the demo and same result.

    ReplyDelete
  2. I've had this issue and fixed it.

    The problems are that the VirtualKeyboardChangeHandler fires too soon. The height of the form (or the keyboard I forgot) isn't initialized when the event fire and that de height property of the virtualkeyboard is always 0.

    We've developed a parralel/timed task framework for internal development. I've placed the code which was executed in the handler in a timedtask so that it is placed later on the call stack.

    By the way we use the VKControlManager solution which you can find on the web and made the following changes for Tokyo:

    private
    ....
    {$IFDEF ANDROID}
    procedure DoVKChanged;
    {$ENDIF}


    uses
    ....
    FMX.Platform.Android,
    Androidapi.JNI.GraphicsContentViewText,


    {$IF Defined(Android)}
    function GetVKBounds: TRectF; overload;
    var
    ContentRect, TotalRect, FocusedRect: JRect;
    begin
    ContentRect := TJRect.Create;
    TotalRect := TJRect.Create;
    FocusedRect := TJRect.Create;

    MainActivity.getWindow.getDecorView.getWindowVisibleDisplayFrame(ContentRect);
    MainActivity.getWindow.getDecorView.getDrawingRect(TotalRect);
    MainActivity.getWindow.getDecorView.getFocusedRect(FocusedRect);

    Result := TRectF.Create(ConvertPixelToPoint(TPointF.Create(TotalRect.Left,
    TotalRect.Top + ContentRect.height)),
    ConvertPixelToPoint(TPointF.Create(TotalRect.Right, TotalRect.Bottom)));
    end;
    {$ENDIF}


    procedure TVKControlManager.VirtualKeyboardChangeHandler(const Sender: TObject; const Msg: TMessage);
    begin
    if not FVKVisible and TVKStateChangeMessage(Msg).KeyboardVisible then
    begin
    FVKVisible := True;
    {$IFDEF ANDROID}
    FList.Add(
    TimedTask('VK',
    procedure
    begin
    DoVKChanged;
    end, 100));
    {$ELSE}
    FVKRect := TVKStateChangeMessage(Msg).KeyboardBounds;
    PositionAdjust;
    {$ENDIF}
    end
    else if FVKVisible and not TVKStateChangeMessage(Msg).KeyboardVisible then
    begin
    FVKVisible := False;
    PositionRestore;
    end;
    end;

    {$IFDEF ANDROID}
    procedure TVKControlManager.DoVKChanged;
    begin
    if Screen.FocusControl <> nil then
    begin
    FVKRect := GetVKBounds;
    PositionAdjust;
    end;
    end;
    {$ENDIF}

    ReplyDelete
  3. No . We use the VKControlManager from

    http://delphiworlds.com/2013/10/moving-controls-into-view-when-the-virtual-keyboard-is-shown/

    The changes make this unit compatible with Delphi Tokyo Android.

    The same concept should apply to other solutions. There are 2 problems:

    - The virtualkeyboard event is fired too soon.
    - The height of the virtualkeboard (in the message from the event) is always 0.

    ReplyDelete
  4. Gert Scholten Thank you! I will try that solution

    ReplyDelete
  5. Gert Scholten I was unable to find VKControlManager on google, so far.

    ReplyDelete
  6. Did you check the link? You can download it there.

    ReplyDelete
  7. Gert Scholten Oh thank you. The link I had lost previously as I deleted a message, but again thank you!!

    ReplyDelete
  8. Gert Scholten H Visli Simply can't make it work :( Even the examples fails. Gert, the sample miss your TimedTask procedure and FList is also not found.

    So far I read this: stackoverflow.com - Delphi FMX - Virtual Keyboard in Android covers control (invalid keyboard height) - read the Gabe Sechan comment.
    Quoted by OP on Stackoverflow https://quality.embarcadero.com/browse/RSP-19001

    ReplyDelete
  9. The example is not complete. It uses a framework we've made ourselves. You need to execute the code in the event (for Android) on a later moment (later on the call stack). You can make you're own method for that.

    This solution works for us on all tested Android devices and about a couple of 100 live installations via the play store.

    ReplyDelete
  10. Oh ok! I will try to implement a similar solution!! Thank you again

    ReplyDelete
  11. Gert Scholten Good lord.. that thing is ancient! ;-) I'm planning to revisit it sometime, however it's good to know it's still useful :-)

    ReplyDelete
  12. David Nottage haha. It still works like a charm... Aftershave fixing some Embarcadero bugs. :-)

    ReplyDelete
  13. David Nottage I am unable to make it work :( my fault.

    ReplyDelete

Post a Comment