Return to Snippet

Revision: 16160
at August 2, 2009 00:19 by keigoi


Updated Code
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]
       return ()
  where
      onEnter input
        = do
          txt <- get input text
          putStrLn txt
          set input [text := ""]

main = enableGUI >> start gui

Revision: 16159
at July 27, 2009 18:55 by keigoi


Initial Code
import EnableGUI -- from http://wxhaskell.sourceforge.net/download/EnableGUI.hs

import Graphics.UI.WXCore hiding (Var)
import Graphics.UI.WX hiding (Var, enter)
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]
       return ()
  where
      onEnter input
        = do
          txt <- get input text
          putStrLn txt
          set input [text := ""]

main = enableGUI >> start gui

Initial URL


Initial Description
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.

Initial Title
Single line textbox in wxHaskell

Initial Tags


Initial Language
Haskell