Computer Science Canada

GUI checkbox labels

Author:  guttface [ Fri Feb 20, 2004 5:20 pm ]
Post subject:  GUI checkbox labels

I'm making a program using GUIs and I was wondering if there was a way to detect the id of a checkbox which has been checked, as well as get the label associated with that checkbox. Thanks.

Author:  Cervantes [ Fri Feb 20, 2004 5:35 pm ]
Post subject: 

I don't even know GUI but I found this easily enough in the help file..... Rolling Eyes

code:

% The "GUI.CreateCheckBoxFull" program.
import GUI

procedure DoNothing (status : boolean)
end DoNothing

View.Set ("graphics:300;100,nobuttonbar")
var cb1 : int := GUI.CreateCheckBox (10, 10, "Check Box 1",
    DoNothing)
var cb2 : int := GUI.CreateCheckBoxFull (200, 10, "Check Box 2",
    DoNothing, GUI.RIGHT, '2')
GUI.SetCheckBox (cb2, true)
var quitBtn : int := GUI.CreateButton (230, 10, 0, "Quit", GUI.Quit)
loop
    exit when GUI.ProcessEvent
end loop
var cb1Status : boolean := GUI.GetCheckBox (cb1)
var cb2Status : boolean := GUI.GetCheckBox (cb2)
if cb1Status then
    put "Check box 1: filled"
else
    put "Check box 1: empty"
end if
if cb2Status then
    put "Check box 2: filled"
else
    put "Check box 2: empty"
end if

Author:  guttface [ Fri Feb 20, 2004 5:50 pm ]
Post subject: 

i wasnt specific enough. this is my code. what i want to happen is when one of the checkboxes is checked, the label of that checkbox is added to the textbox on a new line. how do you do it?
code:
import GUI in "%oot/lib/GUI"
setscreen("graphics:600;600")

var item:array 1..5 of string:=init("Milk","Gum","Cheese","Butter","Eggs")
var box:array 1..5 of int
var textbox:int

procedure write(status:boolean)
%Here's where i'm trying to find the id of the checkbox that was checked %and write its label to the textbox using: GUI.AddLine(textbox,text:string)
end noth

for i1:1..5
box(i1):=GUI.CreateCheckBox(1,maxy-20*i1,item(i1),write)
end for

textbox:=GUI.CreateTextBox(0,0,500,200)

loop
exit when GUI.ProcessEvent
end loop


: