andyhill Posted December 10, 2017 Share Posted December 10, 2017 I have searched the forum and found some entries that dont' work for me (Self.OwnerWebForm.JSInterface etc. I want to add a Listener to a form, simulate the event call (in code) and then catch the event and do something - please advise - thanks. // Listener procedure TMainmForm.UnimFormReady(Sender: TObject); begin //Self.OwnerWebForm.JSInterface.JSAddListener('camera', JSFunction('me', 'var frmWin=' + MainmForm + '.window; ajaxRequest(frmWin, "_photo", [])')); MainmForm.JSInterface.JSAddListener('camera', JSFunction('me', 'var frmWin=' + MainmForm + '.window; ajaxRequest(frmWin, "_photo", [])')); end; ... // Simulate UniSession.AddJS('Ext.form.Panel.form.ajaxCallback(MainmForm, ''_Photo'');'); ... // Catch procedure TMainmForm.UnimFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if SameText(EventName, 'camera') then begin // do something here if 'camera' end; if SameText(EventName, '_photo') then begin // do something here if '_photo' end; end; Link to comment Share on other sites More sharing options...
andyhill Posted December 11, 2017 Author Share Posted December 11, 2017 Farshad, Please comment Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2017 Share Posted December 11, 2017 Hi, "camera" - what event is it ?! Link to comment Share on other sites More sharing options...
andyhill Posted December 11, 2017 Author Share Posted December 11, 2017 My own custom event. I want to be able to throw (generate) a custom event in code and then listen for it elsewhere in code processing it accordingly. Think of it this way, in Delphi I can put an event in the queue:- PostMessage(fGrid.Handle, CM_EDITRECORD, Integer(grDepartmentsDBTableView1), MakeLParam(FocusedRecordIndex, TopRowIndex)); So in JS I understand we need to setup:- 1) Listener 2) Catcher 3) Throw (generate) event Link to comment Share on other sites More sharing options...
andyhill Posted December 13, 2017 Author Share Posted December 13, 2017 Farshad, can you please advise Link to comment Share on other sites More sharing options...
Recommended Posts