Jump to content

UniCalendarPanel & UniPopupMenu


jemmyhatta
 Share

Recommended Posts

Hi,

There're several questions I need to ask:


1. How to show a popupmenu in TUniCalenderPanel only with a single right-click?


2. Every date parts in Calendar Panel can be filled with one or even many events.

The question is: How to count how many events in one date?

Example: If there is no event yet on the date then when the date is clicked a pop up menu showed and the Caption of AddEvent is "enabled=True". And when the count reached some events, Caption of AddEvent on the pop up is "enabled=False".


3. When add event in each date, the clock (time) of that event always appears. Can I hide that? How?


Thanks for the helping.

Best Regards.

Link to comment
Share on other sites

Hi,

 

There're several questions I need to ask:

1. How to show a popupmenu in TUniCalenderPanel only with a single right-click?

 

For now can you try this ?:

 

1. UniMainModule -> BrowserOptions -> [boDisableMouseRightClick = True]

 

2. UniCalendarPanel1 -> ClientEvents -> ExtEvents ->  mousedown fn:

function mousedown(sender, x, y, eOpts)
{
    ajaxRequest(MainForm.form, '_contextmenu', ['x='+x, 'y='+y]);
}

3. MainForm -> ...

procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  x, y: Integer;
begin
  if EventName = '_contextmenu' then
  begin
    x := StrToInt(Params.Values['x']);
    y := StrToInt(Params.Values['y']);
    UniPopupMenu1.Popup(x, y, UniCalendarPanel1);
  end;
end;

Best regards.

Link to comment
Share on other sites

2. Every date parts in Calendar Panel can be filled with one or even many events.

 

The question is: How to count how many events in one date?

 

Example: If there is no event yet on the date then when the date is clicked a pop up menu showed and the Caption of AddEvent is "enabled=True". And when the count reached some events, Caption of AddEvent on the pop up is "enabled=False".

 

Can you use this?:

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  EvtDate: TUniCalendarEvent;
  I: Integer;
begin
  for I := UniCalendarPanel1.Events.Count-1 downto 0 do
  begin
    EvtDate := UniCalendarPanel1.Events[I];
    // your logic
    // EvtDate.StartDate;
    // EvtDate.EndDate;
  end;
end;
Link to comment
Share on other sites

Hi,
Thanks for the hints.
My third question answered, thanks..

For the second question, I cannot use that, because what I want to check is the count of events (how many events) from each date. Let's say there are already three  events on that date, so the FORM /PANEL do not show. But, if less than three events on that date, the form /panel can show up.


And then, what I mean with my first question is not like that, but..

1. When I want to add an event on a date (eg: date 8), then I just click (left-click, default) on that date and the FORM show like on the sample (\FMSoft\Framework\uniGUI\Demos\Desktop\CalendarPanel).

2. If I right-click on the date, a popup menu show.

 

NOTE : see attach files

TesCalenderPanel3.zip

Link to comment
Share on other sites

Hi,

 

For the second question, I cannot use that, because what I want to check is the count of events (how many events) from each date. Let's say there are already three  events on that date, so the FORM /PANEL do not show. But, if less than three events on that date, the form /panel can show up.

 

And what if you will use this ?!:

uses  ... DateUtils;

procedure TMainForm.UniCalendarPanel1DayClick(Sender: TUniCalendarPanel;
  ADate: TDateTime; Allday: Boolean);
var zindex: Integer;
  I: Integer;
  evtCount: Byte;
begin

  evtCount := 0;
  for I := 0 to TUniCalendarPanel(Sender).Events.Count - 1 do
    if CompareDate(TUniCalendarPanel(Sender).Events[I].StartDate, ADate) = 0 then
      Inc(evtCount);

  if evtCount < 3 then
  begin
    // show

  end
  else begin
    //
 
  end;

  ...
end;

Best regards.

Link to comment
Share on other sites

Hi,

 

 

Hi,

 

 

And what if you will use this ?!:

uses  ... DateUtils;

procedure TMainForm.UniCalendarPanel1DayClick(Sender: TUniCalendarPanel;
  ADate: TDateTime; Allday: Boolean);
var zindex: Integer;
  I: Integer;
  evtCount: Byte;
begin

  evtCount := 0;
  for I := 0 to TUniCalendarPanel(Sender).Events.Count - 1 do
    if CompareDate(TUniCalendarPanel(Sender).Events[I].StartDate, ADate) = 0 then
      Inc(evtCount);

  if evtCount < 3 then
  begin
    // show

  end
  else begin
    //
 
  end;

  ...
end;

Best regards.

 

ok, it works. Thanks.

 

 

And how about first question?

Link to comment
Share on other sites

I gave the solution above

if does not work, what's the problem ?!

 

I am sorry about this.   My mistake, I do wrong on implementing the code below. Everything works fine now. Thanks.

 

 

function mousedown(sender, x, y, eOpts)

{

    ajaxRequest(MainForm.form, '_contextmenu', ['x='+x, 'y='+y]);

}

Link to comment
Share on other sites

  • 4 years later...
On 11/4/2016 at 8:47 AM, Sherzod said:

Hi,

 

 

For now can you try this ?:

 

1. UniMainModule -> BrowserOptions -> [boDisableMouseRightClick = True]

 

2. UniCalendarPanel1 -> ClientEvents -> ExtEvents ->  mousedown fn:


function mousedown(sender, x, y, eOpts)
{
    ajaxRequest(MainForm.form, '_contextmenu', ['x='+x, 'y='+y]);
}

3. MainForm -> ...


procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  x, y: Integer;
begin
  if EventName = '_contextmenu' then
  begin
    x := StrToInt(Params.Values['x']);
    y := StrToInt(Params.Values['y']);
    UniPopupMenu1.Popup(x, y, UniCalendarPanel1);
  end;
end;

Best regards.

I wanted to use this example but I'm using the calendar inside a frame and I can't get the right mouse button to work, what procedure can I do?

 

On 11/4/2016 at 8:47 AM, Sherzod said:

Hi,

 

 

For now can you try this ?:

 

1. UniMainModule -> BrowserOptions -> [boDisableMouseRightClick = True]

 

2. UniCalendarPanel1 -> ClientEvents -> ExtEvents ->  mousedown fn:


function mousedown(sender, x, y, eOpts)
{
    ajaxRequest(MainForm.form, '_contextmenu', ['x='+x, 'y='+y]);
}

3. MainForm -> ...


procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  x, y: Integer;
begin
  if EventName = '_contextmenu' then
  begin
    x := StrToInt(Params.Values['x']);
    y := StrToInt(Params.Values['y']);
    UniPopupMenu1.Popup(x, y, UniCalendarPanel1);
  end;
end;

Best regards.

I wanted to use this example but I'm using the calendar inside a frame and I can't get the right mouse button to work, what procedure can I do?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...