Send Focus event when requesting focus. Set focus before sending event

This commit is contained in:
Francisco Vallarino 2020-09-26 18:32:53 -03:00
parent a08fa9f531
commit 47f28ab3cb
3 changed files with 11 additions and 12 deletions

View File

@ -159,7 +159,7 @@ buildUI model = trace "Creating UI" widgetTree where
-- listView textField1 items id,
-- button IncButton "Click!"
-- ] `key` "Main"
widgetTree = traceShow model $ vstack [
widgetTree = vstack [
hstack [
radioV (model ^. fruit) RadioSt Apple,
radioV (model ^. fruit) RadioSt Orange,

View File

@ -143,19 +143,17 @@ handleFocusChange
handleFocusChange systemEvent stopProcessing (wenv, events, widgetRoot)
| focusChangeRequested = do
oldFocus <- use pathFocus
(newWenv1, newEvents1, newRoot1)
<- handleSystemEvent wenv Blur oldFocus widgetRoot
(wenv1, events1, root1) <- handleSystemEvent wenv Blur oldFocus widgetRoot
let newFocus = findNextFocus newWenv1 oldFocus newRoot1
let tempWenv = newWenv1 {
let newFocus = findNextFocus wenv1 oldFocus root1
let tempWenv = wenv1 {
_weFocusedPath = newFocus
}
(newWenv2, newEvents2, newRoot2)
<- handleSystemEvent tempWenv Focus newFocus newRoot1
pathFocus .= newFocus
(wenv2, events2, root2) <- handleSystemEvent tempWenv Focus newFocus root1
return (newWenv2, events >< newEvents1 >< newEvents2, newRoot2)
return (wenv2, events >< events1 >< events2, root2)
| otherwise = return (wenv, events, widgetRoot)
where
focusChangeRequested = not stopProcessing && isKeyPressed systemEvent keyTab
@ -165,12 +163,13 @@ handleFocusSet
=> Seq (WidgetRequest s)
-> HandlerStep s e
-> m (HandlerStep s e)
handleFocusSet reqs previousStep =
handleFocusSet reqs previousStep@(wenv, events, root) =
case Seq.filter isSetFocus reqs of
SetFocus newFocus :<| _ -> do
pathFocus .= newFocus
(wenv2, events2, root2) <- handleSystemEvent wenv Focus newFocus root
return previousStep
return (wenv2, events >< events2, root2)
_ -> return previousStep
handleResize

View File

@ -177,11 +177,11 @@
- Think widget config in a similar way to style config (combinator functions)
- textField should support textFieldV and validInputV
- Add mandatory event parameter for V constructors
- Why does the model update when trying to input a char in FloatingInput?
- Pending
- Why does the model update when trying to input a char in FloatingInput?
- Focus event not received after clicking and gaining focus
- Rethink focus handling. Maybe return list of all focusable elements? Currently shift-tab is not possible
- Rethink focus handling. Maybe return a list of all focusable elements? Currently shift-tab is not possible
- http://hackage.haskell.org/package/data-clist-0.1.2.3
- Think about argument position for widgets, in particular listview/radio
- Should value come before items/option?