Table of Contents

 
DisableButton
 

Purpose

Disables or enables a specific button or all buttons

 

Protoype

void CButtonMngr::DisableButton (bool b_disable, string str_button, exclude ex_list = exclude(), int i_flag = LIST_IN)
 

Parameters

disable whether to disable (TRUE) or enable (FALSE) the button
button the ID of the button to affect, ALL_BUTTONS if changing more than one button object
list the list of sprite objects to exclude or include in function
flag whether to exclude objects not in the list (LIST_OUT) or objects in the list (LIST_IN)
 

Description

This function enables or disables a button. In doing so it actually sets the button's state to disabled, which means the button cannot recieve any mouse or cursor events. You must pass in the ID of the button for str_button as well as whether you want to enable (FALSE) or disable (TRUE) the button.

Enabling/Disabling Multiple Objects

If you want to enable/disable more than one button object at once, then you can use the last two parameters of the function. First you must compile a list (an STL vector) of objects that you want to either exclude or include. If you want to enable/disable all button objects except certain ones, pass those in for ex_list along with the flag LIST_IN. If you want to enable/disable only a certain set of objects, pass those in for ex_list along with the flag LIST_OUT. You should also pass ALL_BUTTONS for str_button.

 

Use

CButtonMngr button;
// enable one button object
button.DisableButton(false, "my_button");
// disable ALL button objects except "my_button"
exclude ex_list;
ex_list.push_back("my_button");
button.DisableButton(true, ALL_BUTTONS, ex_list, LIST_IN);
// enable ONLY these three button objects
exclude ex_list;
ex_list.push_back("my_button1");
ex_list.push_back("my_button2");
ex_list.push_back("my_button3");
button.DisableButton(false, ALL_BUTTONS, ex_list, LIST_OUT);
 

Prev: CheckButtons