bool TBClickLabel::OnEvent(const TBWidgetEvent &ev) { // Get a widget from the layout that isn't the textfield, or just bail out // if we only have the textfield. if (m_layout.GetFirstChild() == m_layout.GetLastChild()) return false; TBWidget *click_target = (m_layout.GetFirstChild() == &m_textfield ? m_layout.GetLastChild() : m_layout.GetFirstChild()); // Invoke the event on it, as if it was invoked on the target itself. if (click_target && ev.target != click_target) { // Focus the target if we clicked the label. if (ev.type == EVENT_TYPE_CLICK) click_target->SetFocus(WIDGET_FOCUS_REASON_POINTER); // Sync our pressed state with the click target. Special case for when we're just about to // lose it ourself (pointer is being released). bool pressed_state = (ev.target->GetAutoState() & WIDGET_STATE_PRESSED) ? true : false; if (ev.type == EVENT_TYPE_POINTER_UP || ev.type == EVENT_TYPE_CLICK) pressed_state = false; click_target->SetState(WIDGET_STATE_PRESSED, pressed_state); TBWidgetEvent target_ev(ev.type, ev.target_x - click_target->GetRect().x, ev.target_y - click_target->GetRect().y, ev.touch, ev.modifierkeys); return click_target->InvokeEvent(target_ev); } return false; }
bool TBMenuWindow::OnEvent(const TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_CLICK && &m_select_list == ev.target) { TBWidgetSafePointer this_widget(this); // Invoke the click on the target TBWidgetEvent target_ev(EVENT_TYPE_CLICK); target_ev.ref_id = ev.ref_id; InvokeEvent(target_ev); // If target got deleted, close if (this_widget.Get()) Close(); return true; } return TBPopupWindow::OnEvent(ev); }
bool TBMessageWindow::OnEvent(const TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_CLICK && ev.target->IsOfType<TBButton>()) { TBWidgetSafePointer this_widget(this); // Invoke the click on the target TBWidgetEvent target_ev(EVENT_TYPE_CLICK); target_ev.ref_id = ev.target->GetID(); InvokeEvent(target_ev); // If target got deleted, close if (this_widget.Get()) Close(); return true; } else if (ev.type == EVENT_TYPE_KEY_DOWN && ev.special_key == TB_KEY_ESC) { TBWidgetEvent click_ev(EVENT_TYPE_CLICK); m_close_button.InvokeEvent(click_ev); return true; } return TBWindow::OnEvent(ev); }