Merge pull request #162 from bollu/checkboxToggle

allow checkboxes to be force-toggled
This commit is contained in:
Henrik Rydgård 2013-10-27 00:51:54 -07:00
commit 2b9efce35b
2 changed files with 7 additions and 2 deletions

View File

@ -383,9 +383,13 @@ void PopupHeader::Draw(UIContext &dc) {
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupTitle.fgColor);
}
EventReturn CheckBox::OnClicked(EventParams &e) {
void CheckBox::Toggle(){
if (toggle_)
*toggle_ = !(*toggle_);
};
EventReturn CheckBox::OnClicked(EventParams &e) {
Toggle();
return EVENT_CONTINUE; // It's safe to keep processing events.
}

View File

@ -600,7 +600,8 @@ public:
virtual void Draw(UIContext &dc);
EventReturn OnClicked(EventParams &e);
//allow external agents to toggle the checkbox
void Toggle();
private:
bool *toggle_;
std::string text_;