Jump to content


Photo

MobileForm Add Listener, Simulate Event In Code, Catch Event

Listener

  • Please log in to reply
4 replies to this topic

#1 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 10 December 2017 - 02:16 AM

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;
 
 
 

 


  • 0

Andy


#2 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 11 December 2017 - 03:43 AM

Farshad, Please comment


  • 0

Andy


#3 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3885 posts

Posted 11 December 2017 - 11:31 AM

Hi,

 

"camera" - what event is it ?!


  • 0

#4 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 11 December 2017 - 06:44 PM

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


  • 0

Andy


#5 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 200 posts
  • LocationMelbourne Australia

Posted 13 December 2017 - 08:13 PM

Farshad, can you please advise


  • 0

Andy





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users