Copyright | (c) 2018 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Input field for time types with support for different formats.
timeField timeLens
With configuration options:
timeField_ timeLens [timeFormatHHMMSS]
Supports TimeOfDay
type of the time
library, but other types can be supported by implementing TimeOfDayConverter
.
Maybe
is also supported.
Handles mouse wheel and shift + vertical drag to increase/decrease minutes.
Synopsis
- data TimeFieldCfg s e a
- type FormattableTime a = (Eq a, Ord a, Show a, TimeTextConverter a, Typeable a)
- data TimeFieldFormat
- class (Eq a, Ord a, Show a, Typeable a) => TimeOfDayConverter a where
- convertFromTimeOfDay :: TimeOfDay -> a
- convertToTimeOfDay :: a -> Maybe TimeOfDay
- class TimeTextConverter a where
- timeAcceptText :: TimeFieldFormat -> Maybe a -> Maybe a -> Text -> (Bool, Bool, Maybe a)
- timeFromText :: TimeFieldFormat -> Text -> Maybe a
- timeToText :: TimeFieldFormat -> a -> Text
- timeFromTimeOfDay' :: TimeOfDay -> a
- timeToTimeOfDay' :: a -> Maybe TimeOfDay
- timeField :: (FormattableTime a, WidgetEvent e) => ALens' s a -> WidgetNode s e
- timeField_ :: (FormattableTime a, WidgetEvent e) => ALens' s a -> [TimeFieldCfg s e a] -> WidgetNode s e
- timeFieldV :: (FormattableTime a, WidgetEvent e) => a -> (a -> e) -> WidgetNode s e
- timeFieldV_ :: (FormattableTime a, WidgetEvent e) => a -> (a -> e) -> [TimeFieldCfg s e a] -> WidgetNode s e
- timeFieldD_ :: (FormattableTime a, WidgetEvent e) => WidgetData s a -> [TimeFieldCfg s e a] -> WidgetNode s e
- timeFormatHHMM :: TimeFieldCfg s e a
- timeFormatHHMMSS :: TimeFieldCfg s e a
Configuration
data TimeFieldCfg s e a Source #
Configuration options for timeField:
validInput
: field indicating if the current input is valid. Useful to show warnings in the UI, or disable buttons if needed.resizeOnChange
: Whether input causes ResizeWidgets requests.selectOnFocus
: Whether all input should be selected when focus is received.readOnly
: Whether to prevent the user changing the input text.minValue
: Minimum valid time.maxValue
: Maximum valid time.wheelRate
: The rate at which wheel movement affects the time.dragRate
: The rate at which drag movement affects the time.onFocus
: event to raise when focus is received.onFocusReq
:WidgetRequest
to generate when focus is received.onBlur
: event to raise when focus is lost.onBlurReq
:WidgetRequest
to generate when focus is lost.onChange
: event to raise when the value changes.onChangeReq
:WidgetRequest
to generate when the value changes.timeFormatHHMM
: accepts HH:MM.timeFormatHHMMSS
: accepts HH:MM:SS.
Instances
type FormattableTime a = (Eq a, Ord a, Show a, TimeTextConverter a, Typeable a) Source #
Constraints for time types accepted by timeField.
data TimeFieldFormat Source #
Available formats for timeField
.
Instances
Eq TimeFieldFormat Source # | |
Defined in Monomer.Widgets.Singles.TimeField (==) :: TimeFieldFormat -> TimeFieldFormat -> Bool # (/=) :: TimeFieldFormat -> TimeFieldFormat -> Bool # | |
Show TimeFieldFormat Source # | |
Defined in Monomer.Widgets.Singles.TimeField showsPrec :: Int -> TimeFieldFormat -> ShowS # show :: TimeFieldFormat -> String # showList :: [TimeFieldFormat] -> ShowS # |
class (Eq a, Ord a, Show a, Typeable a) => TimeOfDayConverter a where Source #
Converter to and form the TimeOfDay
type of the time library. To use types
other than TimeOfDay
of said library, this typeclass needs to be implemented.
-
convertFromTimeOfDay :: TimeOfDay -> a Source #
convertToTimeOfDay :: a -> Maybe TimeOfDay Source #
Instances
class TimeTextConverter a where Source #
Converts a TimeOfDay
instance to and from Text
. Implementing this typeclass
is not necessary for instances of TimeOfDayConverter
.
timeAcceptText :: TimeFieldFormat -> Maybe a -> Maybe a -> Text -> (Bool, Bool, Maybe a) Source #
timeFromText :: TimeFieldFormat -> Text -> Maybe a Source #
timeToText :: TimeFieldFormat -> a -> Text Source #
timeFromTimeOfDay' :: TimeOfDay -> a Source #
timeToTimeOfDay' :: a -> Maybe TimeOfDay Source #
Instances
TimeOfDayConverter a => TimeTextConverter a Source # | |
Defined in Monomer.Widgets.Singles.TimeField timeAcceptText :: TimeFieldFormat -> Maybe a -> Maybe a -> Text -> (Bool, Bool, Maybe a) Source # timeFromText :: TimeFieldFormat -> Text -> Maybe a Source # timeToText :: TimeFieldFormat -> a -> Text Source # timeFromTimeOfDay' :: TimeOfDay -> a Source # timeToTimeOfDay' :: a -> Maybe TimeOfDay Source # | |
(TimeOfDayConverter a, TimeTextConverter a) => TimeTextConverter (Maybe a) Source # | |
Defined in Monomer.Widgets.Singles.TimeField timeAcceptText :: TimeFieldFormat -> Maybe (Maybe a) -> Maybe (Maybe a) -> Text -> (Bool, Bool, Maybe (Maybe a)) Source # timeFromText :: TimeFieldFormat -> Text -> Maybe (Maybe a) Source # timeToText :: TimeFieldFormat -> Maybe a -> Text Source # timeFromTimeOfDay' :: TimeOfDay -> Maybe a Source # |
Constructors
timeField :: (FormattableTime a, WidgetEvent e) => ALens' s a -> WidgetNode s e Source #
Creates a time field using the given lens.
timeField_ :: (FormattableTime a, WidgetEvent e) => ALens' s a -> [TimeFieldCfg s e a] -> WidgetNode s e Source #
Creates a time field using the given lens. Accepts config.
timeFieldV :: (FormattableTime a, WidgetEvent e) => a -> (a -> e) -> WidgetNode s e Source #
Creates a time field using the given value and onChange
event handler.
timeFieldV_ :: (FormattableTime a, WidgetEvent e) => a -> (a -> e) -> [TimeFieldCfg s e a] -> WidgetNode s e Source #
Creates a time field using the given value and onChange
event handler.
Accepts config.
timeFieldD_ :: (FormattableTime a, WidgetEvent e) => WidgetData s a -> [TimeFieldCfg s e a] -> WidgetNode s e Source #
Creates a time field providing a WidgetData
instance and config.
timeFormatHHMM :: TimeFieldCfg s e a Source #
Time format HH:MM
timeFormatHHMMSS :: TimeFieldCfg s e a Source #
Time format HH:MM:SS