Calendar widget Multiple Dates Highlights

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Calendar widget Multiple Dates Highlights

Post by istech » Tue Jul 16, 2024 6:20 am

Hi All,

I do hope all are having a great week.

I have been playing with LC's calendar widget on a project and was wondering if it was possible to highlight multiple dates or change text colour of multiple dates to show an event. Is this something the widget has built in or do you need to build this feature in yourself. Or maybe another option? Would love to hear the communities thoughts on this before going down the rabbit hole. :D

Current properties:
selectedDate
name
headerColor
dayNames
monthNames
foregroundColor
hiliteColor
borderColor
backgroundColor
hiliteStyle

But these only cover selected dates? What about dates that are not selected or am I missing something.
Last edited by istech on Tue Jul 16, 2024 12:20 pm, edited 1 time in total.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Calendar widgets Multiple Dates Highlights

Post by bn » Tue Jul 16, 2024 11:06 am

Hi Istech,

If you are talking about the Calendar widget then it has no option to mark arbitrary dates. Neither does the current Datepicker widget that supersedes the Calendar widget.

However I modified the original Calendar widget by Elanor Buchanan of Livecode to mark days. Additionally I added the option to use the system date names and let the week start on Monday as per ISO.

CalendariusMarkedDays.png
CalendariusMarkedDays.png (35.73 KiB) Viewed 4526 times

Kind regards
Bernd

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Calendar widget Multiple Dates Highlights

Post by istech » Tue Jul 16, 2024 12:23 pm

Wow Bernd,

That is precisely what I need. But fighting a couple hours with the Calendar widget and was just about to dive into Builder to see if I could add the feature in.

Have you got an example I could see?

Many thanks for your time.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Calendar widget Multiple Dates Highlights

Post by bn » Tue Jul 16, 2024 12:49 pm

Hi Istech,

I post a zipped folder that you should put into your "My Livecode" -> "Extensions" folder.
That should install "Calendarius" when you unzip it.

Addidtionally a rough sample stack to put some dates into Calendarius.
I is important to use the sql-format of a date YYYY-MM-DD. If necessary add leading 0's.

Please note that this is based on Elanor Buchanans "Calendar" widget which is heavily modified and extended by me.
If you have problems installing please ask.

setDatesOfCalendarius.livecode.zip
(1.48 KiB) Downloaded 158 times

Kind regards
Bernd
Attachments
community.livecode.berndn.calendarius.1.7.5.zip
(29.9 KiB) Downloaded 134 times

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Calendar widget Multiple Dates Highlights

Post by istech » Tue Jul 16, 2024 4:51 pm

Hi Bernd,

This works perfectly. You are a star and can not thank you enough. When I'm in your country will owe you a drink on me. :D

Thanks for your time.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Calendar widget Multiple Dates Highlights

Post by bn » Tue Jul 16, 2024 6:11 pm

Hi Istech,

Thank you for your kind words.
I tried to load 2000 random dates over 4 years into Calendarius and it worked without a hitch, so you have a lot of leeway.

You could check the datechanged message for a calendar event with something like this in the script of the widget
(or of course anywhere else)

Code: Select all

on dateChanged pDate
   local tMarkedDates, tDate
   put the datesToMark of me into tMarkedDates
   put word 1 of pDate into tDate
   filter tMarkedDates with tDate
   if tMarkedDates is empty then
      put "No Calendar event"
   else
      put "There is a Calender event for " && tDate
   end if
end dateChanged

To load a lot of test data into Calendarius you could to something like this

Code: Select all

on mouseUp
   local tToDoDates
   local tYear, tMonth, tDay
   local tTheYears
   local tTheMonths
   local tTheDays
   local tDatesA, tCount
   
   local t, t1
   put "2020,2021,2022,2023,2024" into tTheYears
   put "01,02,03,04,05,06,07,08,09,10,11,12" into tTheMonths
   put "31,28,31,30,31,30,31,31,30,31,30,31" into tTheDays
   put "2020,2021,2022,2023,2024,2025" into tTheYears
   
   repeat 2000 -- or whatever
      put any item of tTheYears into tYear
      put any item of tTheMonths into tMonth
      put random(item tMonth of tTheDays) into tDay
      if the number of chars of tDay is 1 then
         put 0 before tDay
      end if
      put tYear & "-" & tMonth & "-" & tDay & cr after tToDoDates
   end repeat
   
   put tToDoDates into tDatesA
   split tDatesA by return as set -- eliminate duplicates
   put the keys of tDatesA into tDatesA -- the keys are the dates
   
   put the number of lines of tDatesA into tCount -- the number of dates without dupes

   put the milliseconds into t
   
   set the datesToMark of widget "calendarius" to tDatesA --tToDoDates
   put the milliseconds -t into t1
   put t1 && "ms" && the long time & return & tCount && "NumDates"
end mouseUp
Kind regards
Bernd

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Calendar widget Multiple Dates Highlights

Post by istech » Thu Jul 18, 2024 10:14 am

Hi Bernd,

This works great and is more than enough for what I need. I was thinking just as a side note for the function to accept LC arrays. No need to change anything as this is just my thinking on it.

Again thanks for spending the time on this. Definitely saved me and others a lot of time.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Calendar widget Multiple Dates Highlights

Post by bn » Thu Jul 18, 2024 11:04 am

Hi Istech,
istech wrote:
Thu Jul 18, 2024 10:14 am
This works great and is more than enough for what I need. I was thinking just as a side note for the function to accept LC arrays. No need to change anything as this is just my thinking on it.
The datformat was used to feed data directly from a database query into Calendarius.
One thing that I noticed is that the marker color is not saved. Currently it has to be set by code at startup.

Kind regards
Bernd

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Calendar widget Multiple Dates Highlights

Post by istech » Tue Jul 23, 2024 10:41 am

Hi Bernd,

Again this is not a problem at all. Thanks again for your time on this.

Post Reply