[futurebasic] Radio Buttons

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2008 : Group Archive : Group : All Groups

From: Robert <ke6nij@...>
Date: Wed, 16 Jan 2008 07:39:54 -0800
Hello everyone

I got good advice on this forum so I am coming back for more.

I am writing a demo program that will open a window with three radio buttons.
The first button executes a beep.
The second button executes two beeps with a one second delay between them.
The third button exits the program.

It works but it has a problem.

When the program is first started the first button is selected and 
worse yet it executes the single beep statement.
From then on I can click between the first and second button and it 
beeps and double beeps fine.
The third button is clicked the program exits as it should.

Is there any way to start with three unselected buttons?

And I guess three buttons is the limit so I cannot make a seven button window.

I included the program this time so maybe you can have a look at it.

Thanks,

Robert




// Radio Button Demo

dim centerx, centery, boxx, boxy,x1, y1, x2, y2, loop ,label,i


centerx = window(_width)/2
centery = window(_height)/2
boxx=100
boxy=200

x1 = centerx - boxx
y1 = centery - boxy
x2 = centerx + boxx
y2 = centery + boxy


begin enum 2000
_superParentGroup

_radioOne//2001
_radioTwo//2002
_radioThree//2003
end enum

dim r as rect
dim  lastValue

appearance window 1, "Radio Button Demo", (x1,y1)-(x2,y2), 13
setrect(r,60,60,160,160)

appearance button _superParentGroup, _activeBtn, 0 , 0 , 0 ,
              "" , @r , _kControlRadioGroupProc_useWFont

InsetRect(r,1,1)
r.bottom = r.top + 18


APPEARANCE BUTTON  _radioOne ,  _activeBtn , 0 , 0 , 1 , "BEEP"  , 
@r,_kControlRadioButtonProc_useWFont
DEF EMBEDBUTTON(_radioOne , _superParentGroup) : OffSetRect(r,0,30)

APPEARANCE BUTTON  _radioTwo  ,  _activeBtn , 0 , 0 , 1 , "BEEP BEEP"   
, @r,_kControlRadioButtonProc_useWFont
DEF EMBEDBUTTON(_radioTwo , _superParentGroup) : OffSetRect(r,0,30)

APPEARANCE BUTTON  _radioThree,  _activeBtn , 0 , 0 , 1 , "End Program" 
, @r,_kControlRadioButtonProc_useWFont
DEF EMBEDBUTTON(_radioThree,_superParentGroup)


loop = 0


while not 0

HANDLEEVENTS
i=i+1
long if lastValue != button (_superParentGroup)
lastValue = button (_superParentGroup)
MoveTo(50,window(_height) - 50)

if lastValue = 1 then  beep
if lastValue = 2 then beep : delay 1000 : beep
if lastValue = 3 then end

end if
wend