使用 IFMXVirtualKeyboardService 隐藏后虚拟键盘丢失
Virtual Keyboard is lost after hiding it using IFMXVirtualKeyboardService
我的表格上有一个 TEdit
和一个 TTMSFMXWebGMaps
。在我编辑的 OnKeyUp()
事件中,我有这个代码来隐藏 iPhone 4 的虚拟键盘:
if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService) then
(TPlatformServices.Current.GetPlatformService(IFMXVirtualKeyboardService) as IFMXVirtualKeyboardService).HideVirtualKeyboard;
问题是,如果不将焦点转移到另一个控件,我就无法再次显示键盘。我在我的编辑 OnTap()
中试过这个,但它没有把键盘带回来:
if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService) then
(TPlatformServices.Current.GetPlatformService(IFMXVirtualKeyboardService) as IFMXVirtualKeyboardService).ShowVirtualKeyboard(edSearch);
并且由于我的表单只包含一个 TEdit
,除非用户导航到另一个表单并返回,否则键盘将永远丢失。有什么想法吗?
隐藏虚拟键盘有一个很简单的方法
uses
{$IFDEF IOS}
FMX.Forms
{$ENDIF}
{$IFDEF Android}
Androidapi.JNI.Embarcadero,
FMX.Platform.Android,
FMX.Helpers.Android
{$ENDIF};
procedure HideVirtualKeyboard;
{$IFDEF IOS}
begin
try
Screen.ActiveForm.Focused := nil;
except
end;
end;
{$ENDIF}
{$IFDEF Android}
var
TextView: JFMXTextEditorProxy;
begin
try
begin
TextView := MainActivity.getTextEditorProxy;
CallInUIThread(
procedure
begin
TextView.setFocusable(false);
TextView.setFocusableInTouchMode(false);
TextView.showSoftInput(false);
TextView.clearFocus;
TextView.setFocusable(true);
TextView.setFocusableInTouchMode(true);
end);
end
except
end;
end;
{$ENDIF}
我的表格上有一个 TEdit
和一个 TTMSFMXWebGMaps
。在我编辑的 OnKeyUp()
事件中,我有这个代码来隐藏 iPhone 4 的虚拟键盘:
if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService) then
(TPlatformServices.Current.GetPlatformService(IFMXVirtualKeyboardService) as IFMXVirtualKeyboardService).HideVirtualKeyboard;
问题是,如果不将焦点转移到另一个控件,我就无法再次显示键盘。我在我的编辑 OnTap()
中试过这个,但它没有把键盘带回来:
if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService) then
(TPlatformServices.Current.GetPlatformService(IFMXVirtualKeyboardService) as IFMXVirtualKeyboardService).ShowVirtualKeyboard(edSearch);
并且由于我的表单只包含一个 TEdit
,除非用户导航到另一个表单并返回,否则键盘将永远丢失。有什么想法吗?
隐藏虚拟键盘有一个很简单的方法
uses
{$IFDEF IOS}
FMX.Forms
{$ENDIF}
{$IFDEF Android}
Androidapi.JNI.Embarcadero,
FMX.Platform.Android,
FMX.Helpers.Android
{$ENDIF};
procedure HideVirtualKeyboard;
{$IFDEF IOS}
begin
try
Screen.ActiveForm.Focused := nil;
except
end;
end;
{$ENDIF}
{$IFDEF Android}
var
TextView: JFMXTextEditorProxy;
begin
try
begin
TextView := MainActivity.getTextEditorProxy;
CallInUIThread(
procedure
begin
TextView.setFocusable(false);
TextView.setFocusableInTouchMode(false);
TextView.showSoftInput(false);
TextView.clearFocus;
TextView.setFocusable(true);
TextView.setFocusableInTouchMode(true);
end);
end
except
end;
end;
{$ENDIF}