Computer Science Canada

[tutorial] GUI buttons not depressing

Author:  vlovich [ Wed Jun 04, 2003 10:54 am ]
Post subject:  [tutorial] GUI buttons not depressing

I recently came across this in my program where despite the fact that I was doing exit when GUI.ProcessEvent, my buttons did not depress.

here is an example

code:
setscreen ("offscreenonly")

var but1 := GUI.CreateButton (0,0,0, "Button 1", [i]buttonProc1[/i])
var but2 := GUI.CreateButton (10,10, 0, "Quit", GUI.Quit)

loop
    exit when GUI.ProcessEvent
end loop


the solution turns out to be

code:
setscreen ("offscreenonly")

var but1 := GUI.CreateButton (0,0,0, "Button 1", [i]buttonProc1[/i])
var but2 := GUI.CreateButton (10,10, 0, "Quit", GUI.Quit)

loop
    setscreen ("nooffscreenonly")
    exit when GUI.ProcessEvent
    setscreen ("offscreenonly")
end loop


the obvious advantage of switching between the two in the second example is that you want the button to look nice but don't want ugly flickering if your doing animation with View.Update (for turing 4)[/i]

Author:  Tony [ Wed Jun 04, 2003 12:01 pm ]
Post subject: 

thats because of how GUI is structured. Another way of solving it would be to ether place View.Update inside the loop or throughout the GUI module.


: