Setting Boolean doesn't work

Should this be done by making a new class, or can I just do it in a existing class. And if I put it in a different class and cast to from widget to the class with booleans, what do I put in object? Thanks for your answer.