gpt4 book ai didi

haskell - react 香蕉 react 来检索小部件 textCtrl 值,如 textCtrlGetValue

转载 作者:行者123 更新时间:2023-12-01 02:26:53 24 4
gpt4 key购买 nike

我想检索小部件值。

在下面,按下按钮 b 检索 s_in 并在 native wxhaskell 中打印它。

b <- button f [text:= "print text in console", 
on command := textCtrlGetValue s_in >>= putStrLn]

我喜欢在 react-banana 上做同样的事情,但在下面,我得到“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 。
但是下面的reactimate 行并没有让我得到s_in/b_in 我希望得到的textCtrlGetValue。我怎么才能得到它 ?

最佳答案

使用 behaviorText 获得的行为函数只会对用户对编辑框所做的更改使用react。它不包括程序性更改,例如使用 sink 执行的更改。功能。

区分用户事件和编程事件对于编写具有 bidirectional data flow 的响应式 UI 元素至关重要。 .见 CurrencyConverter example用于演示。

如果您想跟踪程序更改,我建议保持“在 FRP 世界中”,即使用行为 b_out = id <$> b_in而不是尝试从小部件读取文本。

(顺便说一句, id <$> x = x 。)

关于haskell - react 香蕉 react 来检索小部件 textCtrl 值,如 textCtrlGetValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15604213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com