结果:
1.可以处理再次显示问题,但缺点是每个控件都要处理一次,累。哪位大神有好的处理方法,请M我。
实例代码:
1 unit Unit1; 2 3 interface 4 5 uses 6 System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ComboEdit, 8 FMX.Edit, FMX.EditBox, FMX.NumberBox, FMX.DateTimeCtrls, FMX.ScrollBox, 9 FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls,10 FMX.VirtualKeyboard,//需要引入11 FMX.Platform,//需要引入12 FMX.Layouts;13 14 type15 TForm1 = class(TForm)16 VertScrollBox1: TVertScrollBox;17 Layout1: TLayout;18 Memo1: TMemo;19 Label1: TLabel;20 Button1: TButton;21 Edit1: TEdit;22 Edit2: TEdit;23 procedure FormCreate(Sender: TObject);24 procedure FormFocusChanged(Sender: TObject);25 procedure FormVirtualKeyboardHidden(Sender: TObject;26 KeyboardVisible: Boolean; const Bounds: TRect);27 procedure FormVirtualKeyboardShown(Sender: TObject;28 KeyboardVisible: Boolean; const Bounds: TRect);29 procedure Edit2Click(Sender: TObject);30 private31 //定义输入法变量32 FService: IFMXVirtualKeyboardToolbarService;33 FService_kb: FMX.VirtualKeyboard.IFMXVirtualKeyboardService;34 { Private declarations }35 public36 { Public declarations }37 end;38 39 var40 Form1: TForm1;41 42 implementation43 44 { $R *.fmx}45 { $R *.NmXhdpiPh.fmx ANDROID}46 //如果再次点击EDIT应做出反映47 procedure TForm1.Edit2Click(Sender: TObject);48 begin49 if TEdit(Sender).IsFocused and Assigned(FService_kb) then50 try51 FService_kb.ShowVirtualKeyboard(TEdit(Sender));52 except53 end;54 end;55 56 procedure TForm1.FormCreate(Sender: TObject);57 begin58 //控制虚拟键盘的操作59 TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService,60 IInterface(FService_kb));61 if TPlatformServices.Current.SupportsPlatformService62 (IFMXVirtualKeyboardToolbarService, IInterface(FService))then63 begin64 FService.SetToolbarEnabled(true);65 FService.SetHideKeyboardButtonVisibility(true);66 end;67 end;68 69 end.