[Haskell-cafe] haskell-gtk entry question

Claude Heiland-Allen claude at mathr.co.uk
Sat Jul 27 16:44:44 CEST 2013


Hi Brian,

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:

----8<----
import Graphics.UI.Gtk

main :: IO ()
main = do
  initGUI
  window <- windowNew
  entry <- entryNew
  set window [ containerBorderWidth := 10, containerChild := entry ]
  entry `on` entryActivate $ putStrLn =<< entryGetText entry
  onDestroy window mainQuit
  widgetShowAll window
  mainGUI
----8<----

> (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
input?

----8<----
import Control.Monad.Trans (liftIO)
...
  entry `on` focusInEvent $ tryEvent $ liftIO $ putStrLn "focusInEvent"
----8<----


Claude
-- 
http://mathr.co.uk





More information about the Haskell-Cafe mailing list