[Haskell-beginners] Programming GTK
gabre at caesar.elte.hu
gabre at caesar.elte.hu
Fri Jan 6 09:45:03 CET 2012
Hello!
I am writing a turtle graphics program in Haskell. Now, I am working
on the GUI (Gtk2HS). I am a newbie, I have never programmed event
driven systems.
I have a Button, and when it is clicked the code written in a a
TextView is drawn in a DrawingArea. There are some problems: when
"Expose event" happens (I dont really know, if I use the right words,
but I mean, when another window is in focus, or another window comes
before the turtle graphics window etc.) my drawing disappears (I know,
it is the normal behaviour). I would like to redraw it, but I dont
know, how.
I have a function with events...
connectGui gui =
do
onDestroy (mainWin gui) mainQuit
onClicked (btn gui) (drawProgram gui)
afterActivateLeaf (quitbtn gui) (widgetDestroy (mainWin gui))
(where gui is a record, containing all the GUI elements, such as the buttons)
...but the drawProgram function draws everything, and if I add the
"onExpose" with the same drawing function, everything is redrawn
although the Button was never clicked before.
So I would like to modify the code:
-if the button was already clicked and redraw is needed, then it
should be done
-if the button was never clicked, then there must be no redraw
Could you tell me, how can I do this?
Gabre
More information about the Beginners
mailing list