Single line textbox in wxHaskell


/ Published in: Haskell
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. import EnableGUI -- from http://wxhaskell.sourceforge.net/download/EnableGUI.hs
  2.  
  3. import Graphics.UI.WXCore
  4. import Graphics.UI.WX hiding
  5. import Data.Bits ((.&.), complement)
  6.  
  7. textCtrlSetSingleLine ctrl = do
  8. style <- windowGetWindowStyleFlag ctrl
  9. windowSetWindowStyleFlag ctrl (style .&. (complement wxTE_MULTILINE))
  10.  
  11. gui
  12. = do f <- frame [text := "single line textbox sample"]
  13. input <- textCtrlRich f [bgcolor := black, textColor := white, font := fontFixed{ _fontSize = 12 }]
  14. set f [layout := column 1 [hfill (widget input)]]
  15. set input [processEnter := True]
  16. textCtrlSetSingleLine input
  17. set input [on command := onEnter input]
  18. return ()
  19. where
  20. onEnter input
  21. = do
  22. txt <- get input text
  23. set input [text := ""]
  24.  
  25. main = enableGUI >> start gui

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.