DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: fiscan1
今日帖子: 1
在线用户: 3
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 zjcqg (chen) ★☆☆☆☆ -
普通会员
2022/1/21 21:12:47
标题:
解决虚拟键盘输入阻挡遮住 浏览:1233
加入我的收藏
楼主: 有大佬能解决以下典型问题吗?delphi10.4 中edit 或 memo在 android 下,解决虚拟键盘输入阻挡遮住,采用官方的实例,但在这实例有bug,用百度输入法等输入完成后,按那个小箭头返回,会导致edit 或meno不能下移,而且也不能弹出键盘.
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/1/21 22:21:22
1楼: in RAD Studio 11 Alexandria there this procedure for Android:
-- unit FMX.VirtualKeyboard.Android; line 153

function TAndroidVirtualKeyboard.HideVirtualKeyboard: Boolean;
begin
  Result := False;
  try
    if not FTransient then
      Result := MainActivity.getVirtualKeyboard.hide;
  except
    Application.HandleException(Screen.ActiveForm);
  end;
end;

//  for iOS on RAD 11
function TiOSVirtualKeyboardService.HideVirtualKeyboard: Boolean;
begin
  if FTransient then
    Exit(False);

  if SharedApplication.keyWindow = nil then
    Result := False
  else
  begin
    FKeyboardHandler.FKeepFocus := True;
    try
      Result := SharedApplication.keyWindow.endEditing(True);
    finally
      FKeyboardHandler.FKeepFocus := False;
    end;
  end;
end;

**********
see if this "workaround" to iOS and if help you in Android:

by Embarcadero JIRA: 27/Jul/2020 by Alex Gusman
----------
iOS: Virtual Keyboard not switching mode when changing focus between text input controls?

function TCocoaVirtualKeyboardService.HideVirtualKeyboard: Boolean;
var
  Form: TCommonCustomForm;
  View: UIView;
begin
  //if FTransient then    // <- comment out this
  //  Exit(False);        // <- and this
 
  Form := FStoredActiveForm.Form;
  if Form = nil then
    Exit(False);
 
  if Form.Focused = nil then
    View := GetFormView(Form)
  else
    View := GetView(Form.Focused.GetObject);
 
  if View = nil then
    Result := False
  else
  begin
    FKeyboardHandler.FKeepFocus := True;
    try
      Result := View.resignFirstResponder;
    finally
      FKeyboardHandler.FKeepFocus := False;
    end;
  end;
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/1/21 23:08:17
2楼: other thing that you can do is:

---> "override" the EVENTS-procedure on ancestral class, like:

--- in your project:

1) define the new "alternative actions" to "ancestral class"

My sample to "MouseDOWN and MouseUP", but you can use for another events.

unit Unit1;

interface

uses
  System.SysUtils,
  System.Types,
  System.UITypes,
  System.Classes,
  System.Variants,
  FMX.Types,
  FMX.Controls,
  FMX.Forms,
  FMX.Graphics,
  FMX.Dialogs,
  FMX.Controls.Presentation,
  FMX.Edit,
  FMX.Memo.Types,
  FMX.ScrollBox,
  FMX.Memo,
  FMX.StdCtrls;

type
  TEdit = class(FMX.Edit.TEdit) // it's necessary use all namespace for this task ok?
  protected
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single); override;
    procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single); override;
  end;

  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    Memo1: TMemo;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}
{ TEdit }

procedure TEdit.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
  inherited MouseDown(Button, Shift, X, Y); // if you want use "ancestral MouseDown procedure"... here
  //
  Form1.Caption := Format('X: %f, Y:%f - %s', [X, Y, TimeToStr(Now)]);
  //
  // inherited MouseDown(Button, Shift, X, Y); // if you want use "ancestral MouseDown procedure"...  or here
end;

procedure TEdit.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
  inherited MouseDown(Button, Shift, X, Y); // if you want use "ancestral MouseDown procedure"... here
  //
  Form1.Caption := Format('X: %f, Y:%f - %s', [X, Y, TimeToStr(Now)]);
  //
  // inherited MouseDown(Button, Shift, X, Y); // if you want use "ancestral MouseDown procedure"...  or here
end;

end.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/1/22 8:33:57
3楼: the same can be done for any other "class" like TFORM..., TMemo, TButton, etc...

for TMemo and TEDit you can use OnChange"D" event to verify if all is done and so... close keyboard for example.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 zjcqg (chen) ★☆☆☆☆ -
普通会员
2022/1/23 18:26:25
4楼:  emailx45 (emailx45),谢谢你的帮忙解答,可能水平不到,发现还是解决不了问题,请问你有完整的原码吗?
----------------------------------------------
-
作者:
男 glwang (glwang) ★☆☆☆☆ -
盒子活跃会员
2022/1/24 12:33:40
5楼: https://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMX.KeyboardTypes_Sample
----------------------------------------------
作者:
男 zjcqg (chen) ★☆☆☆☆ -
普通会员
2022/2/5 22:00:15
6楼: 官方代码还是没解决问题,主要是中国的输入法如百度输入法右边有个小箭头,可以退出的,而老外的输入法没这个小箭头。
----------------------------------------------
-
作者:
男 glwang (glwang) ★☆☆☆☆ -
盒子活跃会员
2022/2/5 22:42:40
7楼: 或许你可以试试这个组件
http://www.components4developers.com/produicts_kbmFMX.html
----------------------------------------------
作者:
男 zjcqg (chen) ★☆☆☆☆ -
普通会员
2022/2/7 19:19:10
8楼: 经过千方搜寻,终于完美解决,某大佬改写FMX.VirtualKeyboard.Android.pas,在官方代码上,加入FMX.VirtualKeyboard.Android.pas同一目录代替.
此帖子包含附件:zjcqg_202227191910.rar 大小:2,086B
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行80.07813毫秒 RSS