2

I'm using Gtk2Hs to build a GUI drawing some picture in a window. I use the function onExpose to connect the expose event to the redrawing function.

onExpose canvas $ \_ -> do
    refreshArea canvas ... 
    return True

Things are working but in reading the Gtk2Hs documentation, I saw that this function is deprecated and will disappear in next version of Gtk2Hs.

Do you know how to replace the onExpose function to connect the expose event to my funtion for a long time compatibility?

JeanJouX
  • 2,555
  • 1
  • 25
  • 37
  • Could you please provide a link to documentation where it is marked as deprecated? `onExpose` lives in `gtk` package, but `gtk3` uses `exposeEvent` instead. I don't see any deprecation notice in docs. – Yuras Mar 20 '16 at 13:45
  • the link is : https://hackage.haskell.org/package/gtk-0.14.2/docs/Graphics-UI-Gtk-Abstract-Widget.html#v:onExpose – JeanJouX Mar 20 '16 at 14:12
  • Ah, the whole section is deprecated, I never noticed that. Usually the `DEPRECATED` pragma is used for that. Anyway, `exposeEvent` is the way to go. – Yuras Mar 20 '16 at 14:27

1 Answers1

3

You should use new event handling API. In particular you should install a handler for exposeEvent, like the next:

on canvas exposeEvent $ do
  -- do rendering here...
  return True

The same API is provided both by gtk and gtk3 packages.

Yuras
  • 13,856
  • 1
  • 45
  • 58