Jump to content

How To Determine If Calendar Dropped Down Or Closed?


Frederick

Recommended Posts

I have a TUniDateTimePicker control. When the button is clicked and the calendar drops down, how do I know that it has happened? Conversely, how do I tell if the calendar has been closed by the user?

--
Frederick
(UniGUI Complete - Professional Edition 1.90.0.1514)
 

Link to comment
Share on other sites

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniDateTimePicker1, JSInterface do
  begin
    JSAddListener('collapse', JSFunction('', 'ajaxRequest('#1', "collapse");'));
    JSAddListener('expand', JSFunction('', 'ajaxRequest('#1', "expand");'));
  end;
end;

Then in OnAjaxRequest of component, capture the events.

 

if EventName ='...' then
begin
  ... := Params.Values['...'];
end

 

Link to comment
Share on other sites

11 hours ago, Hayri ASLAN said:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniDateTimePicker1, JSInterface do
  begin
    JSAddListener('collapse', JSFunction('', 'ajaxRequest('#1', "collapse");'));
    JSAddListener('expand', JSFunction('', 'ajaxRequest('#1', "expand");'));
  end;
end;

 

Hi Hayri,

Delphi is throwing up the attached error at the following line:-

JSAddListener('collapse', JSFunction('', 'ajaxRequest('#1', "collapse");'));

datStarting is my control's name.

P.S.   When you refer to OnAjaxRequest event of the control, you are actually referring to OnAjaxEvent?

nodefaultjsobj.png

Link to comment
Share on other sites

1 hour ago, Frederick said:

Any help on the above?

What problem do you have? Please make a simple testcase.

On 12/5/2019 at 8:54 AM, Frederick said:

P.S.   When you refer to OnAjaxRequest event of the control, you are actually referring to OnAjaxEvent?

Yes.

ajaxRequest -> OnAjaxEvent

Link to comment
Share on other sites

Frederick,

insert the call in UniFormShow not in UniFormCreate

procedure TMainForm.UniFormShow(Sender: TObject);
begin
  with UniDateTimePicker1, JSInterface do
  begin
    JSAddListener('collapse', JSFunction('', 'ajaxRequest('#1', "collapse");'));
    JSAddListener('expand', JSFunction('', 'ajaxRequest('#1', "expand");'));
  end;
end;

and using OnAjaxEvent to read message

 

if EventName ='...' then
begin
  ... := Params.Values['...'];
end

 

It works

Angelo

 

Link to comment
Share on other sites

7 hours ago, Sherzod said:

What problem do you have? Please make a simple testcase.

Yes.

ajaxRequest -> OnAjaxEvent

The code now works (thanks to Azago) when it is placed in the form's OnShow event. Hayri earlier replied that the code was to in the form's OnCreate event and that caused UniGUI to throw an error.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...