单击 Intraweb 中代码中的按钮(VCL for the Web)
假设我有一个带有 iwEdit(称为 iweLookup)和 iwButton(iwbSearch)的 Intraweb 应用程序(用 Delphi 2010 编写)。当在 iwEdit 中按下 Enter 时,我希望单击 iwButton。
下面的代码几乎可以工作,但我想我需要一些东西来重新渲染页面。
procedure TiwfLookupListing.iweLookupAsyncKeyDown(Sender: TObject;
EventParams: TStringList);
begin
if EventParams.Values['which'] = '13' then
begin
iwbSearchClick(Sender);
end;
end;
然而,这需要往返服务器(这是可以接受的,但不是可取的)。理想情况下,我想要一种在 Javascript 中执行此操作的方法 - 大概是在 iwedit 的 ScriptEvents 中(但我的 Javascript 技能目前,嗯,有限)
任何人都可以指出我正确的方向吗?
Lets say I have an intraweb application (written in Delphi 2010) with an iwEdit (called iweLookup) and an iwButton (iwbSearch). When enter is pressed in the iwEdit, I want the iwButton clicked.
The following code almost works, but I think I need something to re-render the page.
procedure TiwfLookupListing.iweLookupAsyncKeyDown(Sender: TObject;
EventParams: TStringList);
begin
if EventParams.Values['which'] = '13' then
begin
iwbSearchClick(Sender);
end;
end;
However this requires a round trip to the server (which would be acceptable but not desirable). Ideally I'd like a way of doing it in Javascript - presumably in the ScriptEvents for the iwedit (but my Javascript skills are currently, um, limited)
Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我几乎已经解决了这个问题,在按钮的 ScriptEvents 中,对于 onKeyDown 我使用了以下代码:
但是如果有更好的方法来做到这一点......
I've pretty much solved this one, in the ScriptEvents for the button, for onKeyDown I used the following code:
But if there is a better way of doing it...
IWEdits有一个OnSubmit事件,你只需要把按钮的OnClick事件绑定到这个OnSubmit上,只要编辑有焦点,按下回车键就会执行按钮的OnClick。
IWEdits have an OnSubmit event, you just need to bind the OnClick event of the button to this OnSubmit and the buttons OnClick will be executed when you press return, as long as the edit has focus.