/ Published in: Haskell
This snippet shows you how to create a single-line text box, or how to use windowGetWindowStyleFlag.
Press enter to put text in the textbox into the console.
Press enter to put text in the textbox into the console.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import EnableGUI -- from http://wxhaskell.sourceforge.net/download/EnableGUI.hs import Graphics.UI.WXCore import Graphics.UI.WX hiding import Data.Bits ((.&.), complement) textCtrlSetSingleLine ctrl = do style <- windowGetWindowStyleFlag ctrl windowSetWindowStyleFlag ctrl (style .&. (complement wxTE_MULTILINE)) gui = do f <- frame [text := "single line textbox sample"] input <- textCtrlRich f [bgcolor := black, textColor := white, font := fontFixed{ _fontSize = 12 }] set f [layout := column 1 [hfill (widget input)]] set input [processEnter := True] textCtrlSetSingleLine input set input [on command := onEnter input] where onEnter input = do txt <- get input text putStrLn txt set input [text := ""] main = enableGUI >> start gui