1. Home
  2. Docs
  3. DatePicker by Bitsplash
  4. Handling events on the date picker

Handling events on the date picker

This page follows the tutorials that are located in the tutorials folder of the asset



Handling Selection events

Create a script that handles the selection event. For the sake of the tutorial we will use SelectionTutorial.cs that is located in the tutorials folder.

Add an event listener to the selection changed event. See SelectionTutorial.cs for the full script:

 DatePicker.Content.OnSelectionChanged.AddListener(OnSelectionChanged);

Now implement the OnSelectionChangedMethod in any way you would like :

        void OnSelectionChanged()
        {
            ShowAllSelectedDates(); // shows all selected dates
        }

handling Display Events

The display event triggers when the user navigates the date picker (for example when pressing next/prev month).

Create a script that handles the selection event. For the sake of the tutorial we will use DisplayTutorial.cs that is located in the tutorials folder.

Add an event listener to the selection changed event. See DisplayTutorial.cs for the full script:

Picker.Content.OnDisplayChanged.AddListener(DisplayChanged);

Now implement the DisplayChanged method in your script :

    void DisplayChanged()
    {
        InfoText.text = Picker.Content.DisplayDate.ToString("MM-yyyy"); // shows the display date of the picker
    }