[Haskell-cafe] haskell-gtk entry question
claude at mathr.co.uk
Sat Jul 27 16:44:44 CEST 2013
On 25/07/13 04:14, briand at aracnet.com wrote:
> This should be simple, and I thought it had it working, but I've broken it and can't figure out why.
> What I want is to invoke the callback whenever the user activates and entry in a dialogbox, so I did both this :
Not sure what you mean by dialogbox here. A complete (but small)
example would help.
> Gtk.on entry Gtk.entryActivate (boxHandler entry)
Perhaps it's a terminology confusion: in GTK, "activate" for an entry
means "pressing return key". This program works fine for me, pressing
return prints the text I entered in the box:
main :: IO ()
main = do
window <- windowNew
entry <- entryNew
set window [ containerBorderWidth := 10, containerChild := entry ]
entry `on` entryActivate $ putStrLn =<< entryGetText entry
onDestroy window mainQuit
> (I believe this supercedes the previous method which was onEntryActivate)
> and this
> Gtk.on entry Gtk.entryPreeditChanged (boxHandler entry)
> however neither method will invoke the callback. The program compiles and works just fine, it's just that the callback never runs.
Maybe you instead mean to do something when the widget is focussed for
import Control.Monad.Trans (liftIO)
entry `on` focusInEvent $ tryEvent $ liftIO $ putStrLn "focusInEvent"
More information about the Haskell-Cafe