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?
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?
http://www.fmxexpress.com/keep-controls-visible-when-virtual-keyboard-pops-up-in-delphi-10-2-tokyo-on-android-and-ios/
ReplyDeleteH 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.
ReplyDeleteI've had this issue and fixed it.
ReplyDeleteThe 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}
No . We use the VKControlManager from
ReplyDeletehttp://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.
Gert Scholten Thank you! I will try that solution
ReplyDeleteGert Scholten I was unable to find VKControlManager on google, so far.
ReplyDeleteDid you check the link? You can download it there.
ReplyDeleteSorry it was the wrong link. I've just googled TVKControlManager and got one hit:
ReplyDeletehttp://delphiworlds.com/2015/11/moving-controls-into-view-when-the-virtual-keyboard-is-shown-revisited/
Gert Scholten Oh thank you. The link I had lost previously as I deleted a message, but again thank you!!
ReplyDeleteGert 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.
ReplyDeleteSo 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
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.
ReplyDeleteThis solution works for us on all tested Android devices and about a couple of 100 live installations via the play store.
Oh ok! I will try to implement a similar solution!! Thank you again
ReplyDeleteGert Scholten Good lord.. that thing is ancient! ;-) I'm planning to revisit it sometime, however it's good to know it's still useful :-)
ReplyDeleteDavid Nottage haha. It still works like a charm... Aftershave fixing some Embarcadero bugs. :-)
ReplyDeleteDavid Nottage I am unable to make it work :( my fault.
ReplyDelete