Table of Contents

Class TimeField

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

Provides time editing functionality with specialized cursor behavior for time entry.

public class TimeField : TextField, IDisposable, ISupportInitializeNotification, ISupportInitialize, IDesignable
Inheritance
TimeField
Implements
Inherited Members
Extension Methods

Remarks

TimeField extends TextField with time-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, FieldLength]
  • Numeric input replaces characters in-place rather than inserting
  • Delete operations replace digits with '0' rather than removing characters
  • Supports both short (HH:mm) and long (HH:mm:ss) formats

Cursor Position Model:

  • InsertionPoint: Inherited, but constrained by the override to [1, FieldLength]
  • AdjustInsertionPoint(int, bool): Adjusts cursor to skip over time separator characters
  • Terminal.Gui.Views.TimeField.IncrementInsertionPoint()/Terminal.Gui.Views.TimeField.DecrementInsertionPoint(): Move cursor while respecting separator positions

Example: For long format "HH:mm:ss" with text " 14:30:45":

  • Position 0: Leading space (not user-accessible)
  • Positions 1-2: Hour digits (14)
  • Position 3: Separator ':' (cursor skips over)
  • Positions 4-5: Minute digits (30)
  • Position 6: Separator ':' (cursor skips over)
  • Positions 7-8: Second digits (45)

Constructors

TimeField()

Initializes a new instance of TimeField.

Properties

InsertionPoint

Gets or sets the cursor position within the time field, constrained to valid digit positions.

IsShortFormat

Get or sets whether TimeField uses the short or long time format.

Time

Gets or sets the time of the TimeField.

Methods

DeleteCharLeft(bool)

Deletes the character to the left.

DeleteCharRight()

Deletes the character to the right.

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.

OnTimeChanged(EventArgs<TimeSpan>)

Event firing method that invokes the TimeChanged event.

Events

TimeChanged

TimeChanged event, raised when the Date has changed.