DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: 33227
今日帖子: 17
在线用户: 9
导航: 论坛 -> 移动应用开发 斑竹:flyers,iamdream  
作者:
男 tms2021 (TMS2021) ▲△△△△ -
普通会员
2022/11/18 12:21:07
标题:
Delphi Android程序,如何触发回车事件? 浏览:1401
加入我的收藏
楼主: Delphi Android程序,如何触发回车事件(keydown keyup 都试了没有用 )。回车是pda扫码后给的一个回车
----------------------------------------------
欢迎加入Delphi的QQ群:462884906
作者:
男 1111111113 (1111111113) ▲△△△△ -
普通会员
2022/11/18 12:39:20
1楼: 安卓有键盘事件的
按此在新窗口浏览图片
delphi 不清楚底层了。
----------------------------------------------
-
作者:
男 sail2000 (小帆工作室) ★☆☆☆☆ -
盒子活跃会员
2022/11/18 13:25:58
2楼: procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  if Key = vkReturn then
  begin
    Memo1.Lines.Add('按了回车')
  end;
end;
此帖子包含附件:
PNG 图像
大小:31.5K
----------------------------------------------
delphi 是兴趣,和工作无关,即使它倒闭。又不靠它 delphi 吃饭,怕甚?
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/11/18 18:11:22
3楼: KeyDown or KeyPress events: any component (forms, edits, etc...)

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if (Key = 13) then
    ShowMessage('ENTER KeyDown');
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if (Key = Chr(13) { #13 } ) then
    ShowMessage('ENTER KeyPress');
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 tms2021 (TMS2021) ▲△△△△ -
普通会员
2022/11/19 10:05:46
4楼: When Return in tedit,the KeyDown/KeyPress event,can't catch retun!

On the form or memo ,can catch retun!
----------------------------------------------
欢迎加入Delphi的QQ群:462884906
作者:
男 tms2021 (TMS2021) ▲△△△△ -
普通会员
2022/11/19 15:43:11
5楼: android下
再form,memo里可以捕捉触发回车键
,在点再edit的时候,无法触发回车事件
----------------------------------------------
欢迎加入Delphi的QQ群:462884906
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/11/19 15:54:43
6楼: 变通下 memo 当edit用 按此在新窗口浏览图片
我记得 vcl下可以拦截消息 这个方法适用fmx吗?
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 tms2021 (TMS2021) ▲△△△△ -
普通会员
2022/11/19 16:04:13
7楼: TO:keymark
是的,我现在就这么干了
----------------------------------------------
欢迎加入Delphi的QQ群:462884906
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/11/19 22:49:27
8楼: MEMO dont capture "RETURN key" by default!
--  "non-printable characters are captured" to internal process and cannot be handled easyly, it's necessary change the "FMX" internal use of JAVA class
in "C:\RADStudio\RX112\source\rtl\androiddex\java\fmx\src\com\embarcadero\firemonkey\text\FMXEditText.java"  or others


More easy, try this: FORM "OnKeyDown" occurs before that your childs 

implementation

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.OnKeyDown := MyOnKeyDown;
  Memo1.OnKeyDown := MyOnKeyDown;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  Label1.Text := TimeToStr(now) + ' FORM: key = ' + Key.ToString;
end;

procedure TForm1.MyOnKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  Label2.Text := TimeToStr(now) + ' CONTROL: key = ' + Key.ToString;
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/11/20 2:35:17
9楼: another solution more complicated would be Daniele Tetti (MVP) solution to Android + RETURN key:

https://www.danielespinetti.it/2017/03/intercept-keyevent-on-android-with.html

Intercept KeyEvent on Android with Delphi
Some days ago, I had the needed to intercept the KeyDown Event on Android. In particullary the App have to respond to FormKeyDown Event. After some work I found out that there is an opened issue about this topic (https://quality.embarcadero.com/browse/RSP-10111 - vote it if you need its resolution). So I set to work to find a solution/workaround to solve my need. I studied Android SDK and Delphi internal mechanism and I found out a way to resolve it:
By adding a JFMXTextListener to JFMXTextEditorProxy
JFMXTextEditorProxy is an object provided by the JFMXNativeActivity (The activity for all your Android application in Delphi) and provides the method addTextListener to register a JFMXTextListener.
JFMXTextListener is an interface that supply 3 methods to manage text event:

   procedure onComposingText(beginPosition: Integer; endPosition: Integer); cdecl;
   procedure onSkipKeyEvent(event: JKeyEvent); cdecl;
   procedure onTextUpdated(text: JCharSequence; position: Integer); cdecl;

.... read more on link
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 tms2021 (TMS2021) ▲△△△△ -
普通会员
2022/11/20 10:54:01
10楼: what is MyOnKeyDown?
----------------------------------------------
欢迎加入Delphi的QQ群:462884906
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/11/21 8:03:51
11楼: MyOnKeyDown is same that "OnKeyDown event on forms/components"

TForm1
...
public / private
-> procedure MyOnKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
...
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/11/21 8:08:43
12楼: type
  TForm1 = class(TForm)
...
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
    procedure Memo1ChangeTracking(Sender: TObject);
  private
    procedure MyOnKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
  public
   // to MSWindows messages...
    procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.OnKeyDown := MyOnKeyDown;
  Memo1.OnKeyDown := MyOnKeyDown;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  Label1.Text := TimeToStr(now) + ' FORM: key = ' + Key.ToString;
end;

procedure TForm1.MyOnKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
  Label2.Text := TimeToStr(now) + ' CONTROL: key = ' + Key.ToString;
end;

procedure TForm1.Memo1ChangeTracking(Sender: TObject);
begin
  Label3.Text := TimeToStr(now) + Sender.ClassName;
end;

procedure TForm1.WMKeyDown(var Message: TWMKeyDown);
begin
  // if message.CharCode = vkReturn then
  Label4.Text := TimeToStr(now) + ' CharCode=' + message.CharCode.ToString;
  //
  inherited;
end;

end.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 tms2021 (TMS2021) ▲△△△△ -
普通会员
2022/11/28 9:21:37
13楼: 经测试,在11.2中tedit已经可成功捕捉回车键事件,结贴
----------------------------------------------
欢迎加入Delphi的QQ群:462884906
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行82.03125毫秒 RSS