Futurebasic/Language/Reference/def embedbutton
DEF EMBEDBUTTON Statement
[edit | edit source]DEF EMBEDBUTTON
[edit | edit source]Statement
[edit | edit source]✔ Appearance ✔ Standard ✔ Console
Syntax
[edit | edit source]DEF EMBEDBUTTON(childButtonID&, parentButtonID&)
Revised
[edit | edit source]February 2002 (Release 6)
Description
[edit | edit source]The appearance manager can embed several buttons (sub controls) within a single parent button (or super control). In fact, buttons may be embedded in buttons which are in turn embedded in other buttons. The advantages are enormous. Take this example: each window has a single root control. All buttons within the window are embedded into this root control or into one of its children. When the window becomes inactive, the root control is disabled. With that single command (implemented by the FB runtime) all other controls in the window are automatically disabled.
The versatility extends to things like showing or hiding a pane in a tab control or buttons within a group.
Example
[edit | edit source]The following example creates a radio button group and embeds individual buttons into the super control. As a result, you can poll the group button to find out which of the radio sub controls is currently selected.
image d/DEF%20EMBEDBUTTON02.gif
DIM r as rect
DIM pR as rect
DIM h as handle
DIM bRef as long
DIM err as OSErr
// create a window
SETRECT(r,0,0,_btnWd_btnMargin_btnMargin,120)
APPEARANCE WINDOW 1,,@r
err = FN SETTHEMEWINDOWBACKGROUND( window( _wndPointer ),¬
_kThemeActiveDialogBackgroundBrush, _zTrue )
// button #1 is the papa button
// note that the parent button has sufficient space so that // it holds all embedded buttons within its own rectangle
SETRECT(r,_btnMargin,_btnMargin,¬
_btnMargin_btnWd,(_btnMargin_btnHt)*3)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"",@r,_kControlRadioGroupProc
bRef ++
SETRECT(r,_btnMargin,_btnMargin,_btnMargin_btnWd,¬
_btnMargin_btnHt)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"Radio 1",@r,_kControlRadioButtonProc
DEF EMBEDBUTTON(bRef,1)
bRef ++ : offsetrect(r,0,_btnHt_btnMargin)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"Radio 2",@r,_kControlRadioButtonProc
DEF EMBEDBUTTON(bRef,1)
bRef ++ : offsetrect(r,0,_btnHt_btnMargin)
APPEARANCE BUTTON bRef,_activeBtn,0,0,1,¬
"Radio 3",@r,_kControlRadioButtonProc
DEF EMBEDBUTTON(bRef,1)
LOCAL FN handleDialog
DIM AS LONG action,reference
action = DIALOG(0)
reference = DIALOG(action)
LONG IF action = _btnclick
MOVETO(8,100)
PRINT "Current Button ";button(1);
END IF
END FN
ON DIALOG FN handleDialog
DO
HANDLEEVENTS
UNTIL 0