Class DateField
Provides date editing functionality with specialized cursor behavior for date entry.
public class DateField : TextField, IDisposable, ISupportInitializeNotification, ISupportInitialize, IDesignable
- Inheritance
-
DateField
- Implements
- Inherited Members
- Extension Methods
Remarks
DateField extends TextField with date-specific cursor behavior:
- Cursor positions are constrained to valid digit positions (skipping separators)
- Position 0 is reserved for a leading space; valid cursor range is [1, FormatLength]
- Numeric input replaces characters in-place rather than inserting
- Delete operations replace digits with '0' rather than removing characters
Cursor Position Model:
- InsertionPoint: Inherited, but constrained by the override to [1, FormatLength]
- AdjustInsertionPoint(int, bool): Adjusts cursor to skip over date separator characters
- Terminal.Gui.Views.DateField.IncrementInsertionPoint()/Terminal.Gui.Views.DateField.DecrementInsertionPoint(): Move cursor while respecting separator positions
Example: For format "MM/dd/yyyy" with text " 01/15/2024":
- Position 0: Leading space (not user-accessible)
- Positions 1-2: Month digits (01)
- Position 3: Separator '/' (cursor skips over)
- Positions 4-5: Day digits (15)
- Position 6: Separator '/' (cursor skips over)
- Positions 7-10: Year digits (2024)
Constructors
- DateField()
Initializes a new instance of DateField.
- DateField(DateTime)
Initializes a new instance of DateField.
Properties
- Culture
CultureInfo for date. The default is CultureInfo.CurrentCulture.
- InsertionPoint
Gets or sets the cursor position within the date field, constrained to valid digit positions.
Methods
- DeleteCharLeft(bool)
Deletes the character to the left.
- DeleteCharRight()
Deletes the character to the right.
- OnDateChanged(EventArgs<DateTime>)
Event firing method for the DateChanged event.
- OnKeyDownNotHandled(Key)
Called when the user has pressed key it wasn't handled by KeyDown and was not bound to a key binding.
- OnMouseEvent(Mouse)
Called when a mouse event occurs within the view's Viewport.
Events
- DateChanged
DateChanged event, raised when the Date property has changed.