开发者

Click a button in code in Intraweb (VCL for the Web)

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开发者_JAVA百科 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?


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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜