Haskell 使用reactimate检索小部件textCtrl值,如textCtrlGetValue
我想检索小部件的值 在下面的示例中,按按钮b在中检索s_,并用原生wxhaskell打印它Haskell 使用reactimate检索小部件textCtrl值,如textCtrlGetValue,haskell,reactive-programming,reactive-banana,Haskell,Reactive Programming,Reactive Banana,我想检索小部件的值 在下面的示例中,按按钮b在中检索s_,并用原生wxhaskell打印它 b <- button f [text:= "print text in console", on command := textCtrlGetValue s_in >>= putStrLn] b>=putStrLn] 我喜欢在反应型香蕉上做同样的事情,但在下面的例子中,我得到的是“ff”,而不是s_in2的textCtrlGetValue s_in
b <- button f [text:= "print text in console",
on command := textCtrlGetValue s_in >>= putStrLn]
b>=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
力矩t()
networkDescription=do
b_in使用
behaviorText
功能获得的行为只会对用户对编辑框所做的更改做出反应。它不包括编程更改,如使用sink
函数执行的更改
区分用户事件和编程事件对于编写具有响应性的UI元素至关重要。有关演示,请参见
如果您想跟踪编程更改,我建议您“在FRP世界内”,即使用行为b_out=id b_in
,而不是尝试从小部件读取文本
(顺便说一下,
idx=x
)首先感谢您的快速回答。我确实注意到了双向数据流,当时想知道为什么它没有循环!现在,我知道了,谢谢!我以前没有注意到这种重要的概念分离。现在我跨越的另一个主题()是如何让模型和GUI交互,记住模型不是GUI或WX特定的(示例中的图形不是小部件依赖关系图(在FRP中是典型的),而是表示