Bob asked:
> I haven't got radio buttons and check boxes working yet...
Bob,
In addition to Brian's nice checkbox demo, here's a quickie for roll-
your-own radio buttons the old-fashioned way. Once you understand
this, progress to grouping the radio buttons in a group box which
makes retrieving the selected button's value easy to capture with a
single event. The next step is to build a nib in Interface Builder
the hard code it in FB.
I originally wrote this demo heavily remarked, but I cut out the
remarks to post here. If you find the code difficult to understand,
let me know and I'll forward the remarked version.
I'll suggest one exercise for you: Add two more radio buttons to this
code and also put a Quit button in the window, and post the results
here for a friendly critique.
Ken
_radioBtnOne = 1
_radioBtnTwo = 2
_radioBtnThree = 3
_radioOffAtStartup = 0
_radioOnAtStartup = 1
_radioOffState = 0
_radioOnState = 1
local fn BuildRadioButtonWindow
'~'1
window 1, "Radio Button Window", (0,0)-(180,150), _docNoGrow
appearance button _radioBtnOne, _activeBtn,¬
_radioOnAtStartup_radioOffState,¬
_radioOnState, "Radio Button 1",¬
( 20,20 )-( 150,39 ),¬
_kControlRadioButtonProc
appearance button _radioBtnTwo, _activeBtn,¬
_radioOffAtStartup, _radioOffState,¬
_radioOnState, "Radio Button 2",¬
( 20,40 )-( 150,59 ),¬
_kControlRadioButtonProc
appearance button _radioBtnThree, _activeBtn,¬
_radioOffAtStartup, _radioOffState,¬
_radioOnState, "Radio Button 3",¬
( 20,60 )-( 150,79 ),¬
_kControlRadioButtonProc
end fn
local fn PrintButtonID( whichButtonIsOn as long )
'~'1
text _sysFont, 13
moveto( 25, 110 )
cls line
print "Selected button is:"; whichButtonIsOn
end fn
local fn SetRadioButtons( whichButtonIsOn as long )
dim as long i
'~'1
for i = _radioBtnOne to _radioBtnThree
long if ( i == whichButtonIsOn )
appearance button i,,_radioOnState
xelse
appearance button i,,_radioOffState
end if
next
fn PrintButtonID( whichButtonIsOn )
end fn
local fn DoDialog
dim as long evnt, id
'~'1
evnt = dialog(0)
id = dialog(evnt)
select case( evnt )
case _wndClose : end
case _btnClick
select( id )
case _radioBtnOne : fn SetRadioButtons( 1 )
case _radioBtnTwo : fn SetRadioButtons( 2 )
case _radioBtnThree : fn SetRadioButtons( 3 )
end select
end select
end fn
on dialog fn DoDialog
fn BuildRadioButtonWindow
fn PrintButtonID( _radioBtnOne )
do
handleevents
until gFBQuit