From: Axel S. <Axe...@en...> - 2008-07-10 11:01:58
|
On Thu, 2008-07-10 at 20:29 +1000, Chris Mears wrote: > Axel Simon <Axe...@en...> writes: > > > You have to pass in the DrawWindow of the enclosing Window widget. I > > don't quite understand why, but here's an alternative to your program > > without using the IORef: > > > > G.onExposeRect da $ const $ do > > dw <- G.widgetGetDrawWindow w > > mPos <- G.drawWindowGetPointer dw > > case mPos of > > Just (_, x, y, _) -> do > > dw <- G.widgetGetDrawWindow da > > gc <- G.gcNew dw > > G.drawRectangle dw gc True (x-5) (y-5) 10 10 > > Nothing -> return () > > > > Axel. > > Hi Axel, > > Thanks for your speedy reply. This alone isn't quite what I want, > because it updates the rectangle's position only on expose events -- > should it be combined with something to regularly generate expose > events? The only time you should draw to the canvas is in the onExpose signal. If you need to update the widget's contents periodically, you should just generate a new onExpose signal by calling widgetRedrawAll from a timer. (See earlier email on the Cairo clock example). Axel. |