Reactive banana reanimation to get the widget textCtrl Value, for example textCtrlGetValue

I would like to get the value of the widget.

Next, by pressing the b button, you will get s_in and print it in your own wxhaskell.

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

I like to do the same on reactive banana, but in the next I get "ff" and not textCtrlGetValue s_in2

 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 

The shell updates well sin_2 after s_in. but the next resuscitation line doesn't get me the textCtrlGetValue s_in / b_in that I want to get. How can I β€œget” it?

+4
source share
1 answer

The behavior obtained using the behaviorText function will only respond to changes made by the user in the edit field. It does not include programmatic changes, such as those made using the sink function.

The distinction between user events and program events is important for writing sensitive user interface elements that have a bi-directional data stream . See the CurrencyConverter example for a demo.

If you want to track software changes, I recommend staying β€œinside the FRP world”, i.e. use the behavior b_out = id <$> b_in instead of reading the text from the widget.

(By the way, id <$> x = x .)

+3
source

All Articles