单击 Intraweb 中代码中的按钮(VCL for the Web)

发布于 2024-09-14 23:25:16 字数 540 浏览 2 评论 0原文

假设我有一个带有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无需解释 2024-09-21 23:25:16

我几乎已经解决了这个问题,在按钮的 ScriptEvents 中,对于 onKeyDown 我使用了以下代码:

if (event.which == 13) {
  IWBSEARCH_onclick(event);
  return false;
} else {
  return true;
}

但是如果有更好的方法来做到这一点......

I've pretty much solved this one, in the ScriptEvents for the button, for onKeyDown I used the following code:

if (event.which == 13) {
  IWBSEARCH_onclick(event);
  return false;
} else {
  return true;
}

But if there is a better way of doing it...

习惯成性 2024-09-21 23:25:16

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文