getField IntValue working

This commit is contained in:
David Davó 2021-06-24 17:27:57 +02:00
parent 71d98d915a
commit 3dd254a4e4
4 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,7 @@
# IPython widget messaging specification version 2
The model implemented is the Model State v8, for ipywidgets 7.4., @jupyter-widgets/base 1.1., and @jupyter-widgets/controls 1.4.*.
> Largely based on: https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/messages.md
> The messaging specification as detailed is riddled with assumptions the IHaskell widget
@ -29,7 +31,7 @@ The initial state must *at least* have the following fields in the `data.state`
- `_view_module_version`
- `_view_name`
You can see more info on the model state of widgets [here](https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/jupyterwidgetmodels.latest.md).
You can see more info on the model state of widgets [here](https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/jupyterwidgetmodels.v8.md).
> Warning!: By default there are two widgets modules: `@jupyter-widgets/controls` and `@jupyter-widgets/base`.

View File

@ -281,5 +281,5 @@ nestedObjectLookup :: Value -> [Text] -> Maybe Value
nestedObjectLookup val [] = Just val
nestedObjectLookup val (x:xs) =
case val of
Object o -> maybe Nothing (`nestedObjectLookup` xs) $ HM.lookup x o
Object o -> (`nestedObjectLookup` xs) =<< HM.lookup x o
_ -> Nothing

View File

@ -58,7 +58,7 @@ mkIntSlider = do
instance IHaskellWidget IntSlider where
getCommUUID = uuid
comm widget val _ =
case nestedObjectLookup val ["sync_data", "value"] of
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
void $ setField' widget IntValue (Sci.coefficient value)
triggerChange widget

View File

@ -652,10 +652,10 @@ reflect = fromSing
-- | A record representing a Widget class from IPython from the controls modules
defaultControlWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> Rec Attr WidgetClass
defaultControlWidget viewName modelName = (ViewModule =:: "@jupyter-widgets/controls")
:& (ViewModuleVersion =:: "2.0.0")
:& (ViewModuleVersion =:: "1.4.0")
:& (ViewName =:: viewName)
:& (ModelModule =:: "@jupyter-widgets/controls")
:& (ModelModuleVersion =:: "2.0.0")
:& (ModelModuleVersion =:: "1.4.0")
:& (ModelName =:: modelName)
:& (MsgThrottle =:+ 3)
:& (DisplayHandler =:: return ())