Skip to content

Introducing Dateslider and DateRangeSlider#177

Open
slootsjj wants to merge 6 commits intomathworks:masterfrom
slootsjj:datesliders
Open

Introducing Dateslider and DateRangeSlider#177
slootsjj wants to merge 6 commits intomathworks:masterfrom
slootsjj:datesliders

Conversation

@slootsjj
Copy link
Contributor

This PR introduces two date UI widgets. They combine native sliders with non-editable date pickers for day-level selection with consistent formatting and events.

New components

1. DateSlider — single-date selector with:

  • Value (datetime) and ValueIndex (days-from-lower-limit) synchronization
  • Limits (datetime[2]) with start-of-day normalization
  • DisplayFormat passthrough to both slider tick labels and date picker
  • Optional Orientation (horizontal/vertical) and DatepickerSize
  • Events: ValueChanged, ValueChanging, LimitsChanged

2. DateRangeSlider — two-date range selector with:

  • Value (datetime[2]) and ValueIndex (days-from-lower-limit) synchronization
  • Limits (datetime[2]) with start-of-day normalization
  • MinGap (enforces minimum days between start/end)
  • DisplayFormat, Orientation, DatepickerSize
  • Events: ValueChanged, ValueChanging, LimitsChanged
  • Note: Compatible with MATLAB R2024b or higher.

UX & behavior
Tick labels auto-scale from limits using the chosen DisplayFormat
Arrow buttons step by property Step (a calendarDuration) and auto-disable at bounds

Additional note

  • The TickableDateSlider mixin class was introduced to support these widgets.
  • The icons up_grey_12.png and down_grey_12.png were added to support these widgets.
  • WidgetsList.mlx was updated to include these widgets.

Rationale
Provides a consistent, accessible way to pick single dates or ranges with clear ticks, bounded interactions, and unified events.

@rjackey
Copy link
Member

rjackey commented Feb 5, 2026

@slootsjj thank you for your contribution and my apologies I've not had a chance to review yet. It is still on my task list and I hopefully will have some time in a couple weeks.

@rjackey rjackey self-assigned this Feb 12, 2026
@rjackey rjackey added the enhancement New feature or request label Feb 12, 2026
Copy link
Member

@rjackey rjackey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slootsjj these are nice contributions, thank you!

In testing these out I am getting an issue with onSliderChanging of DateRangeSlider when dragging.

It seems the round() might put the date outside the limits?

  Error using matlab.ui.control.DatePicker/set.Value (line 148)
  'Value' must be a finite datetime object within the range of 'Limits' or NaT.
  
  Error in wt.DateRangeSlider/onSliderChanging (line 452)
              obj.DatepickerLeft.Value = changedDate(1);
              ^^^^^^^^^^^^^^^^^^^^^^^^
  Error in wt.DateRangeSlider>@(h,e)obj.onSliderChanging(e) (line 274)
              obj.Slider.ValueChangingFcn = @(h,e)obj.onSliderChanging(e);

Also just a note if you like you can add app designer metadata, or I can try to do so later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants