接管unigui手机物理返回按键

接管unigui屏蔽手机物理返回按键

如果不接管,手机一按物理返回键,会立即关闭程序。

下面是接管后,会有提示:

 

1

 

procedure TMainmForm.UnimFormCreate(Sender: TObject);
begin
 UniSession.AddJS('$(document).ready(function() {'
   + ' if (window.history && window.history.pushState) { '
   + ' $(window).on("popstate", function() { '
   + ' if (confirm("确定要退出应用吗?")) {'
    + ' window.close();'
   + ' } else { '
   + ' window.history.pushState("forward", null, "#");'
   + ' window.history.forward(1); '
   + ' }'
   + ' });'
   + ' } '
   + ' window.history.pushState("forward", null, "#"); '
   + ' window.history.forward(1);'
   + '});  ' );

end;

 

posted @ 2025-12-17 10:21  delphi中间件  阅读(24)  评论(0)    收藏  举报