Threepenny-gui: how to get the text?

With "set text" in Threepenny-gui, you can set an element and a string to set the text of that element:

Prelude Graphics.UI.Threepenny.Core> :t set
set :: ReadWriteAttr x i o -> i -> UI x -> UI x
Prelude Graphics.UI.Threepenny.Core> :t set text
set text :: String -> UI Element -> UI Element

      

The existence of get functions makes me think that it should be possible to get text with a given element.

Prelude Graphics.UI.Threepenny.Core> :t get
get :: ReadWriteAttr x i o -> x -> UI o
Prelude Graphics.UI.Threepenny.Core> :t text
text :: WriteAttr Element String
Prelude Graphics.UI.Threepenny.Core> :t get text
get text :: Element -> UI ()

      

However, the return type 'get text' is not what I expect. How do I restore the original string from an element?

+3


source to share


1 answer


If I remember correctly, the problem is that the text value of the element includes all of its subelements as HTML code. I recommend using that instead value

, which works for input fields.



ReadAttr

and WriteAttr

implemented in terms ReadWriteAttr

to avoid overload. As the types indicate, get

does nothing useful for WriteAttr

, and set

does not do anything useful for ReadAttr

.

+1


source







All Articles