Jump to content

MobileForm Add Listener, Simulate Event In Code, Catch Event


andyhill

Recommended Posts

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

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

×
×
  • Create New...