我想检索小部件值. 在下面,按下按钮b检索s_in并在本机wxhaskell中打印它. b - button f [text:= "print text in console", on command := textCtrlGetValue s_in = putStrLn] 我喜欢在反应香蕉上做同样的事,但在下面
在下面,按下按钮b检索s_in并在本机wxhaskell中打印它.
b <- button f [text:= "print text in console", on command := textCtrlGetValue s_in >>= putStrLn]
我喜欢在反应香蕉上做同样的事,但在下面,我得到“ff”而不是s_in2的textCtrlGetValue
s_in <- textCtrl f [] s_in2 <- textCtrl f [] b <- button f [text:= "print text in console", on command := textCtrlGetValue s_in >>= putStrLn] let networkDescription :: forall t. Frameworks t => Moment t () networkDescription = do b_in <- behaviorText s_in "init" b_in2 <- behaviorText s_in2 "ff" e_butt <- event0 b command -- I need an event, triggered by the button, and filled by the b_in2, sink s_in2 [text :== id <$> b_in] reactimate $ (\x -> putStrLn x) <$> b_in2 <@ e_butt
在s_in之后,接收器更新了sin_2.
但是下面的重新获取行没有得到我希望获得的s_in / b_in的textCtrlGetValue.我怎么才能得到它 ?
区分用户事件和编程事件对于编写具有bidirectional data flow的响应式UI元素至关重要.请参阅CurrencyConverter example进行演示.
如果你想跟踪程序化的变化,我建议保持“在FRP世界中”,即使用行为b_out = id< $> b_in而不是尝试从小部件中读取文本.
(顺便说一下,id< $> x = x.)