Page 1 of 1
Calendar widget Multiple Dates Highlights
Posted: Tue Jul 16, 2024 6:20 am
by istech
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.
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.
Re: Calendar widgets Multiple Dates Highlights
Posted: Tue Jul 16, 2024 11:06 am
by bn
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 (35.73 KiB) Viewed 4519 times
Kind regards
Bernd
Re: Calendar widget Multiple Dates Highlights
Posted: Tue Jul 16, 2024 12:23 pm
by istech
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.
Re: Calendar widget Multiple Dates Highlights
Posted: Tue Jul 16, 2024 12:49 pm
by bn
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.
Kind regards
Bernd
Re: Calendar widget Multiple Dates Highlights
Posted: Tue Jul 16, 2024 4:51 pm
by istech
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.
Thanks for your time.
Re: Calendar widget Multiple Dates Highlights
Posted: Tue Jul 16, 2024 6:11 pm
by bn
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
Re: Calendar widget Multiple Dates Highlights
Posted: Thu Jul 18, 2024 10:14 am
by istech
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.
Re: Calendar widget Multiple Dates Highlights
Posted: Thu Jul 18, 2024 11:04 am
by bn
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
Re: Calendar widget Multiple Dates Highlights
Posted: Tue Jul 23, 2024 10:41 am
by istech
Hi Bernd,
Again this is not a problem at all. Thanks again for your time on this.