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

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 15 Jan 2012 06:18:32 -0500
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:

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

Off or on, unchecked or checked, 0 or 1, are the only two values of an old-style FB checkbox.

A programmer can, of course, deactivate the button-- or change its state--  by setting it
to _grayBtn. But an inactive checkbox button does not generate a dialog event and it
would take intervention in code to reactivate it as either active or marked so it can
return a usable value.

As far back as I can remember, the demo below represents the traditional
handling of a vanilla FB checkbox button.

I think you are confusing value and state, which would be easy with a vanilla FB
checkbox because in creating something easy to use, the two parameters are kludged
into one. FB's button( id, _FBGetCtlRawValue ) will only return a button's value, not its state.

I realize in the FB help under "button [function]" it says that

   buttonState = button( btnNum [,selector] )

This wording is unfortunate since "buttonState" returns the actual state of the control in
only a very limited context. The function sees most use in returning  min-max-current values,
the control's handle, hierarchy, etc.

On the other hand, an FB Appearance Button separates the state and value parameters
and allows extended settings such as a mixed value checkbox.


local fn DoDialog
dim as short ev, id

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

select ( ev )
case _btnClick
select ( id )
case ( 1203 )     // Button named Bold
if ( button ( 1203 ) )
button 1203, _activeBtn : beep : delay 100 : beep
button 1203, _markedBtn : beep
end if
case ( 1204 )     // Button named Gray
// You will never get here since no event is generated
// for a button in an inactive state
stop "You clicked the button named Gray"
end select
end select
end fn

local fn addButton
button 1203, _activeBtn, "Bold", ( 20, 124 )-( 120, 144 ), _checkBox
button 1204, _grayBtn,   "Gray", ( 20, 154 )-( 120, 174 ), _checkBox
end fn

on dialog Fn DoDialog

window 1
fn addButton

until gFBQuit