Haskell Gi-GTK noob here. And GTK noob in general.
I have an image, which I've wrapped in an Eventbox. Now, I want to detect when the user presses on the event box (mousedown). Some Googling points me to using button-press-event
. My code is below.
drag <- imageNewFromFile "rszh.png"
dragevents <- eventBoxNew
containerAdd dragevents drag
set dragevents [widgetHalign := AlignEnd, widgetValign := AlignEnd]
onWidgetButtonPressEvent dragevents (print "Hello world")
And GHC fails to compile this with the following cryptic error message:
panedraggin.hs:30:42: error:
• Couldn't match type ‘IO ()’
with ‘GI.Gdk.Structs.EventButton.EventButton -> IO Bool’
Expected type: GI.Gtk.Objects.Widget.WidgetButtonPressEventCallback
Actual type: IO ()
• Possible cause: ‘print’ is applied to too many arguments
In the second argument of ‘onWidgetButtonPressEvent’, namely
‘(print "Hello world")’
In a stmt of a 'do' block:
onWidgetButtonPressEvent dragevents (print "Hello world")
In the expression:
do { Gtk.init Nothing;
window <- windowNew WindowTypeToplevel;
onWidgetDestroy window mainQuit;
windowMaximize window;
.... }
What am I doing incorrectly?