Below is a simple example using gtk2hs that adds a label and then a click handler on it. The buttonPressEvent handler is never called when you click on the label. The button could be put in a container, but... do containers fire the button pressed signal?
I have a rectangular area that has some text in it (currently using label) that I need to know if the user clicked in it. I don't want it to look like a button.
{-# LANGUAGE PackageImports #-}
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.EventM
import Graphics.UI.Gtk.Gdk.GC
import "mtl" Control.Monad.Trans(liftIO)
main = do
initGUI
window <- windowNew
window `onDestroy` mainQuit
label0 <- labelNew $ Just "static label"
widgetAddEvents label0 [ButtonPressMask] -- is this necessary? Still doesn't work with it, though
label0 `on` buttonPressEvent $ tryEvent $ do
liftIO $ putStrLn "static label clicked"
containerAdd window label0
widgetShowAll window
mainGUI
You want to use an event-box for that. It's a container that captures events.
Here's a version that works.