Calendar

Package: Libraries.Interface.Controls · Inherits from: Libraries.Interface.Item, Libraries.Interface.Controls.Control, Libraries.Interface.Item2D, Libraries.Language.Object, Libraries.Interface.Events.MouseMovementListener

A Calendar shows one month, to choose a date from. At the top are the month and year, such as "November 2026", between buttons for the previous and next months. Below are the weekdays and six weeks of days, starting on Sunday unless set otherwise (SetFirstDayOfWeek). Days of the months before and after are dimmed, today has a ring, the chosen day is filled with the accent color, and while the calendar has the focus, a ring marks the current day, the one the keys are on. Days outside the allowed range (SetMinimumDate and SetMaximumDate) are dimmed, struck through, and can't be chosen. The keys: Left and Right move a day, Up and Down a week, Home and End to the first and last day of the week, Page Up and Page Down a month, and Shift with Page Up and Page Down a year. Moving past the month shows the next one. Enter or Space chooses the current day. A click on a day chooses it, and a click on another month's day moves there. Listeners (AddCalendarListener) are told when the user chooses a day. The days are drawn by the calendar, not made of controls of their own. Screen readers learn about them through GetShownDay, GetDaySpokenText and the other actions here, and each day says itself in full, such as "Thursday, November 12, 2026, today, selected". The calendar's name is the month shown, such as "November 2026". Its colors come from the interface options under the key "Calendar": the background color is behind the days, the font color is the days' numbers, the foreground color is dimmed days, the border color is today's ring, the accent color fills the chosen day (its number is white), and the focus border color is the ring around the current day.

Example Code

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Form form
Page page = form:GetMainPage()

Calendar calendar
CalendarDate due
due:SetDate(2026, 11, 20)
calendar:SetDate(due)
page:Add(calendar)

form:Display()

Actions

AddCalendarListener(Libraries.Interface.Events.CalendarListener listener)

This action adds a listener, told when the user chooses a day.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Events.CalendarListener

Calendar calendar
CalendarListener listener
calendar:AddCalendarListener(listener)

BeginMouseOver()

This action is called when the mouse moves onto the calendar. The calendar's own background doesn't change; only the day under the mouse is marked, as it moves.

ChooseCurrentDay()

This action chooses the current day as the user does, as Enter and Space do: it is filled with the accent color, and listeners are told. A day outside the allowed range can't be chosen.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:ChooseCurrentDay()

ChooseDayAt(number x, number y)

This action responds to a click or touch at a place on the screen: a day of the month shown is chosen, a day of another month is moved to, and an unavailable day is left alone. The calendar takes the focus.

Parameters

  • x number: Where the pointer is, across the screen.
  • y number: Where the pointer is, up the screen.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:ChooseDayAt(120, 80)

EndMouseOver()

This action is called when the mouse leaves the calendar: no day is marked as under it.

GainedFocus(Libraries.Interface.Events.FocusEvent event)

This action is called when the calendar gains the focus: the current day gets its ring.

Parameters

GetCurrentDay()

This action returns the current day: the one the keys are on, which has the focus ring while the calendar has the focus. Screen readers put their focus on it.

Returns

Libraries.System.CalendarDate: A copy of the current day.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate day = calendar:GetCurrentDay()

GetDate()

This action returns the chosen day, or undefined if none is chosen.

Returns

Libraries.System.CalendarDate: A copy of the chosen day, or undefined.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate date = calendar:GetDate()

GetDateField()

This action returns the date field whose pop-up the calendar is in, or undefined for a calendar on its own.

Returns

Libraries.Interface.Controls.DateField: The date field, or undefined.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Controls.DateField

Calendar calendar
DateField field = calendar:GetDateField()

GetDaySpokenText(Libraries.System.CalendarDate date)

This action returns what a screen reader says for a day: the date in words, then ", today", ", selected" and ", unavailable" where they apply, such as "Thursday, November 12, 2026, today, selected".

Parameters

Returns

text: The day in words.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
text words = calendar:GetDaySpokenText(calendar:GetCurrentDay())

GetDisplayedMonth()

This action returns the month shown, from 1 (January) to 12 (December).

Returns

integer: The month.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
integer month = calendar:GetDisplayedMonth()

GetDisplayedYear()

This action returns the year of the month shown.

Returns

integer: The year.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
integer year = calendar:GetDisplayedYear()

GetFirstDayOfWeek()

This action returns the day weeks start on: 1 is Monday and 7 is Sunday.

Returns

integer: The first day of the week.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
integer first = calendar:GetFirstDayOfWeek()

GetMaximumDate()

This action returns the latest day that can be chosen, or undefined if there is no limit.

Returns

Libraries.System.CalendarDate: A copy of the latest day, or undefined.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate latest = calendar:GetMaximumDate()

GetMinimumDate()

This action returns the earliest day that can be chosen, or undefined if there is no limit.

Returns

Libraries.System.CalendarDate: A copy of the earliest day, or undefined.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate earliest = calendar:GetMinimumDate()

GetNextMonthButton()

This action returns the button that shows the next month.

Returns

Libraries.Interface.Controls.Button: The next month button.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Controls.Button

Calendar calendar
Button next = calendar:GetNextMonthButton()

GetPreviousMonthButton()

This action returns the button that shows the previous month.

Returns

Libraries.Interface.Controls.Button: The previous month button.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Controls.Button

Calendar calendar
Button previous = calendar:GetPreviousMonthButton()

GetShownDay(integer row, integer column)

This action returns the day shown at a place in the grid of six rows and seven columns. Row 0 is the top week and column 0 is the first day of the week. The first row starts with the week holding the first of the month, so some days are from the months before and after. A place outside the grid returns undefined.

Parameters

  • row integer: The week, from 0 to 5.
  • column integer: The day of the week, from 0 to 6.

Returns

Libraries.System.CalendarDate: The day, or undefined.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate topLeft = calendar:GetShownDay(0, 0)

GetWeekdayName(integer column)

This action returns the full name of the weekday in a column, such as "Sunday" for column 0 when weeks start on Sunday. Screen readers use it as the column's header. A column outside 0 to 6 returns an empty text.

Parameters

  • column integer: The column, from 0 to 6.

Returns

text: The weekday's name.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
text first = calendar:GetWeekdayName(0)

IsAvailable(Libraries.System.CalendarDate date)

This action returns whether a day can be chosen: whether it is inside the range set with SetMinimumDate and SetMaximumDate.

Parameters

Returns

boolean: True if the day can be chosen.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate date
date:SetDate(2026, 11, 12)
boolean available = calendar:IsAvailable(date)

IsInDisplayedMonth(Libraries.System.CalendarDate date)

This action returns whether a day is in the month shown, not one of the dimmed days of the months before and after.

Parameters

Returns

boolean: True if the day is in the month shown.

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
boolean inMonth = calendar:IsInDisplayedMonth(calendar:GetShownDay(0, 0))

IsRenderingMouseOver()

This action returns false: the calendar marks the day under the mouse, not its whole background.

Returns

boolean: false.

LoadGraphics(Libraries.Interface.Layouts.LayoutProperties properties)

This action loads the calendar's graphics: its background, the days' circles and the month buttons' chevrons, then colors the days. The game engine calls it as needed, so most users won't need to call it directly.

Parameters

LostFocus(Libraries.Interface.Events.FocusEvent event)

This action is called when the calendar loses the focus: the current day's ring is hidden.

Parameters

MoveCurrentDay(integer days)

This action moves the current day by a number of days, as the arrow keys do, showing another month when it must. It stops at the ends of the allowed range.

Parameters

  • days integer: How many days to move: negative for earlier days.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
// A week later, as the Down key does.
calendar:MoveCurrentDay(7)

MoveCurrentMonth(integer months)

This action moves the current day by a number of months, as Page Up and Page Down do, keeping the day of the month, or the month's last day if it is shorter.

Parameters

  • months integer: How many months to move: negative for earlier months.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:MoveCurrentMonth(1)

MoveCurrentYear(integer years)

This action moves the current day by a number of years, as Shift with Page Up and Page Down does.

Parameters

  • years integer: How many years to move: negative for earlier years.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:MoveCurrentYear(-1)

MoveToWeekEnd()

This action moves the current day to the last day of its week, as End does.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:MoveToWeekEnd()

MoveToWeekStart()

This action moves the current day to the first day of its week, as Home does.

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:MoveToWeekStart()

MovedMouse(Libraries.Interface.Events.MouseEvent event)

This action is called when the mouse moves over the calendar: the day under it gets a light circle in the mouse-over color, unless it can't be chosen.

Parameters

RemoveCalendarListener(Libraries.Interface.Events.CalendarListener listener)

This action removes a listener.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Events.CalendarListener

Calendar calendar
CalendarListener listener
calendar:AddCalendarListener(listener)
calendar:RemoveCalendarListener(listener)

SetDate(Libraries.System.CalendarDate date)

This action sets the chosen day as a program does: the calendar shows its month and the keys move from it, but listeners aren't told, since the user didn't choose it. With undefined, no day is chosen.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate date
date:SetDate(2026, 11, 12)
calendar:SetDate(date)

SetDateField(Libraries.Interface.Controls.DateField field)

This action sets the date field whose pop-up the calendar is in, so Escape closes it. DateField calls it, so most users won't need to.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Controls.DateField

DateField field
Calendar calendar
calendar:SetDateField(field)

SetDisplayedMonth(integer year, integer month)

This action shows a month. The current day moves to the same day of that month, or its last day if the month is shorter, kept in the allowed range.

Parameters

  • year integer: The year, such as 2026.
  • month integer: The month, from 1 (January) to 12 (December).

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
calendar:SetDisplayedMonth(2027, 1)

SetFirstDayOfWeek(integer day)

This action sets the day weeks start on, numbered as ISO 8601 does: 1 is Monday and 7 is Sunday. Weeks start on Sunday unless set.

Parameters

  • day integer: The first day of the week, from 1 (Monday) to 7 (Sunday).

Example

use Libraries.Interface.Controls.Calendar

Calendar calendar
// Weeks start on Monday.
calendar:SetFirstDayOfWeek(1)

SetMaximumDate(Libraries.System.CalendarDate date)

This action sets the latest day that can be chosen, or undefined for no limit. Later days are dimmed and struck through, and the keys stop there.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate last
last:SetDate(2026, 12, 31)
calendar:SetMaximumDate(last)

SetMinimumDate(Libraries.System.CalendarDate date)

This action sets the earliest day that can be chosen, or undefined for no limit. Earlier days are dimmed and struck through, and the keys stop there.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.System.CalendarDate

Calendar calendar
CalendarDate today
today:SetToToday()
calendar:SetMinimumDate(today)

SetNextFocus(Libraries.Interface.Item item)

This action sets where the focus goes after the calendar. Tab goes from the days to the previous and next month buttons, then to the item given.

Parameters

Example

use Libraries.Interface.Controls.Calendar
use Libraries.Interface.Controls.Button

Calendar calendar
Button done
calendar:SetNextFocus(done)

Inherited Actions

258 actions from Libraries.Interface.Controls.Control
1 action from Libraries.Interface.Events.MouseMovementListener
60 actions from Libraries.Interface.Item
202 actions from Libraries.Interface.Item2D
3 actions from Libraries.Language.Object