MCPcopy Create free account
hub / github.com/cinience/RedisStudio / SelectItem

Method SelectItem

DuiLib/Control/UICombo.cpp:254–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254bool CComboUI::SelectItem(int iIndex, bool bTakeFocus)
255{
256 if( m_pWindow != NULL ) m_pWindow->Close();
257 if( iIndex == m_iCurSel ) return true;
258 int iOldSel = m_iCurSel;
259 if( m_iCurSel >= 0 ) {
260 CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]);
261 if( !pControl ) return false;
262 IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
263 if( pListItem != NULL ) pListItem->Select(false);
264 m_iCurSel = -1;
265 }
266 if( iIndex < 0 ) return false;
267 if( m_items.GetSize() == 0 ) return false;
268 if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1;
269 CControlUI* pControl = static_cast<CControlUI*>(m_items[iIndex]);
270 if( !pControl || !pControl->IsVisible() || !pControl->IsEnabled() ) return false;
271 IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
272 if( pListItem == NULL ) return false;
273 m_iCurSel = iIndex;
274 if( m_pWindow != NULL || bTakeFocus ) pControl->SetFocus();
275 pListItem->Select(true);
276 if( m_pManager != NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMSELECT, m_iCurSel, iOldSel);
277 Invalidate();
278
279 return true;
280}
281
282bool CComboUI::SetItemIndex(CControlUI* pControl, int iIndex)
283{

Callers 1

HandleMessageMethod · 0.45

Calls 8

IsVisibleMethod · 0.80
IsEnabledMethod · 0.80
SendNotifyMethod · 0.80
CloseMethod · 0.45
GetInterfaceMethod · 0.45
SelectMethod · 0.45
GetSizeMethod · 0.45
SetFocusMethod · 0.45

Tested by

no test coverage detected