[futurebasic] Re: [FB] state = Button (Id) reports 1 less than actual

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

From: Bernie <fblist.bw@...>
Date: Sun, 15 Jan 2012 18:51:40 +0000
Ken wrote:

> Robert Covington wrote:
> 
>> Active control, but state = Button(ID) reports _grayBtn state. _FBGetCtlRawValue...same thing.
> 
> Perhaps I'm dense, but I fail to grasp your logic. A vanilla FB checkbox button
> dialog event returns either:

Haven't checked, but it wouldn't surprise me if there is a bug in FBtoC's button statement translation.

> [A]. An  unchecked event value of 0 (indicating an _activeBtn
> [B]. A checked event value of 1 (indicating a  _markedBtn)

The fact that _activeBtn = 1 and _markedBtn = 2 may lead to confusion.  I wonder if it'd be clearer to test for _kControlCheckBoxUncheckedValue (0) and _kControlCheckBoxCheckedValue (1) ?

btw, possibly better to create checkbox with appearance button statement which allows auto toggle type.

'---------------
local fn DoDialog
'~'1
dim as short ev, id
dim as SInt32 value

ev = dialog( 0 )
id = dialog( ev )

select ( ev )
case _btnClick
select ( id )
case 1203
value = button( id, _FBGetCtlRawValue )

print value

select ( value )
case _kControlCheckBoxUncheckedValue

case _kControlCheckBoxCheckedValue

end select
end Select
end select
end fn

local fn AddButton
//button 1203, _activeBtn, "Bold", (20,124)-(120,144), _checkBox
appearance button 1203, _activeBtn, _kControlCheckBoxUncheckedValue,,, "Bold", (20,124)-(120,144), _kControlCheckBoxAutoToggleProc
end fn

on dialog fn DoDialog

window 1
fn AddButton

do
HandleEvents
until ( gFBQuit )
'---------------