jemmyhatta Posted November 4, 2016 Posted November 4, 2016 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. Quote
Sherzod Posted November 4, 2016 Posted November 4, 2016 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. Quote
Sherzod Posted November 4, 2016 Posted November 4, 2016 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; Quote
Sherzod Posted November 4, 2016 Posted November 4, 2016 3. When add event in each date, the clock (time) of that event always appears. Can I hide that? How? Use: Event.IsAllDay := True; Please look and analyze this demo example: \FMSoft\Framework\uniGUI\Demos\Desktop\CalendarPanel Quote
jemmyhatta Posted November 7, 2016 Author Posted November 7, 2016 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 Quote
Sherzod Posted November 7, 2016 Posted November 7, 2016 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. Quote
jemmyhatta Posted November 7, 2016 Author Posted November 7, 2016 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? Quote
Sherzod Posted November 7, 2016 Posted November 7, 2016 And how about first question? I gave the solution above if does not work, what's the problem ?! Quote
jemmyhatta Posted November 7, 2016 Author Posted November 7, 2016 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]); } Quote
eduardosuruagy Posted March 12, 2021 Posted March 12, 2021 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? Quote
Sherzod Posted March 13, 2021 Posted March 13, 2021 15 hours ago, eduardosuruagy said: but I'm using the calendar inside a frame Hello, Could you create a test case? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.