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 |
Monomer.Widgets.Singles.NumericField
Contents
Description
Input field for numeric types.
Supports instances of the FromFractional
typeclass. Several basic types are
implemented, both for integer and floating point types.
Handles mouse wheel and shift + vertical drag to increase/decrease the number.
Synopsis
- data NumericFieldCfg s e a
- type FormattableNumber a = (Eq a, Ord a, Show a, NumericTextConverter a, Typeable a)
- class NumericTextConverter a
- numericField :: (FormattableNumber a, WidgetEvent e) => ALens' s a -> WidgetNode s e
- numericField_ :: (FormattableNumber a, WidgetEvent e) => ALens' s a -> [NumericFieldCfg s e a] -> WidgetNode s e
- numericFieldV :: (FormattableNumber a, WidgetEvent e) => a -> (a -> e) -> WidgetNode s e
- numericFieldV_ :: (FormattableNumber a, WidgetEvent e) => a -> (a -> e) -> [NumericFieldCfg s e a] -> WidgetNode s e
Configuration
data NumericFieldCfg s e a Source #
Configuration options for numericField:
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.minValue
: Minimum valid number.maxValue
: Maximum valid number.wheelRate
: The rate at which wheel movement affects the number.dragRate
: The rate at which drag movement affects the number.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.decimals
: the maximum number of digits after the decimal separator. Defaults to zero for integers and two for floating point types.
Instances
type FormattableNumber a = (Eq a, Ord a, Show a, NumericTextConverter a, Typeable a) Source #
Constraints for numeric types accepted by numericField.
class NumericTextConverter a Source #
Converts a numeric instance to and from Text
.
Minimal complete definition
numericAcceptText, numericFromText, numericToText, numericToFractional, numericFromFractional
Instances
FromFractional a => NumericTextConverter a Source # | |
Defined in Monomer.Widgets.Singles.NumericField Methods numericAcceptText :: Maybe a -> Maybe a -> Int -> Text -> (Bool, Bool, Maybe a) numericFromText :: Text -> Maybe a numericToText :: Int -> a -> Text numericToFractional :: Fractional b => a -> Maybe b numericFromFractional :: (Real b, Fractional b) => b -> a | |
(FromFractional a, NumericTextConverter a) => NumericTextConverter (Maybe a) Source # | |
Defined in Monomer.Widgets.Singles.NumericField Methods numericAcceptText :: Maybe (Maybe a) -> Maybe (Maybe a) -> Int -> Text -> (Bool, Bool, Maybe (Maybe a)) numericFromText :: Text -> Maybe (Maybe a) numericToText :: Int -> Maybe a -> Text numericToFractional :: Fractional b => Maybe a -> Maybe b numericFromFractional :: (Real b, Fractional b) => b -> Maybe a |
Constructors
numericField :: (FormattableNumber a, WidgetEvent e) => ALens' s a -> WidgetNode s e Source #
Creates a numeric field using the given lens.
numericField_ :: (FormattableNumber a, WidgetEvent e) => ALens' s a -> [NumericFieldCfg s e a] -> WidgetNode s e Source #
Creates a numeric field using the given lens. Accepts config.
numericFieldV :: (FormattableNumber a, WidgetEvent e) => a -> (a -> e) -> WidgetNode s e Source #
Creates a numeric field using the given value and onChange
event handler.
numericFieldV_ :: (FormattableNumber a, WidgetEvent e) => a -> (a -> e) -> [NumericFieldCfg s e a] -> WidgetNode s e Source #
Creates a numeric field using the given value and onChange
event handler.
Accepts config.