コード例 #1
2
ファイル: uiradiobutton.cpp プロジェクト: highfestiva/life
bool RadioButton::OnLButtonUp(int mouse_x, int mouse_y) {
	if (IsOver(mouse_x, mouse_y) == true) {
		Component* parent = GetParent();
		Layout* layout = parent->GetLayout();

		// Update all the other radio buttons.
		Component* child = layout->GetFirst();
		while (child != 0) {
			if (child != this && child->GetType() == Component::kRadiobutton) {
				RadioButton* button = (RadioButton*)child;
				button->SetPressed(false);
			}

			child = layout->GetNext();
		}

		SetPressed(true);
		Click(true);
	} else {
		// Go back to previous state.
		switch(GetState()) {
		case kReleasing:
			SetState(kPressed);
			break;
		case kPressing:
			SetState(kReleased);
			break;
		default:
			break;
		}
	}

	ReleaseMouseFocus();
	return true;
}