TBWindow *TBWindow::GetTopMostOtherWindow(bool only_activable_windows) { TBWindow *other_window = nullptr; TBWidget *sibling = GetParent()->GetLastChild(); while (sibling && !other_window) { if (sibling != this) other_window = TBSafeCast<TBWindow>(sibling); if (only_activable_windows && other_window && !(other_window->m_settings & WINDOW_SETTINGS_CAN_ACTIVATE)) other_window = nullptr; sibling = sibling->GetPrev(); } return other_window; }
bool TBSelectList::ChangeValue(SPECIAL_KEY key) { if (!m_source || !m_layout.GetContentRoot()->GetFirstChild()) return false; bool forward; if (key == TB_KEY_HOME || key == TB_KEY_DOWN) forward = true; else if (key == TB_KEY_END || key == TB_KEY_UP) forward = false; else return false; TBWidget *item_root = m_layout.GetContentRoot(); TBWidget *current = GetItemWidget(m_value); TBWidget *origin = nullptr; if (key == TB_KEY_HOME || (!current && key == TB_KEY_DOWN)) current = item_root->GetFirstChild(); else if (key == TB_KEY_END || (!current && key == TB_KEY_UP)) current = item_root->GetLastChild(); else origin = current; while (current) { if (current != origin && !current->GetDisabled()) break; current = forward ? current->GetNext() : current->GetPrev(); } // Select and focus what we found if (current) { SetValue(current->data.GetInt()); return true; } return false; }