本文整理汇总了C++中ListboxItem::isSelected方法的典型用法代码示例。如果您正苦于以下问题:C++ ListboxItem::isSelected方法的具体用法?C++ ListboxItem::isSelected怎么用?C++ ListboxItem::isSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListboxItem
的用法示例。
在下文中一共展示了ListboxItem::isSelected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMouseButtonDown
/*************************************************************************
Handler for when mouse button is pressed
*************************************************************************/
void Listbox::onMouseButtonDown(MouseEventArgs& e)
{
// base class processing
Window::onMouseButtonDown(e);
if (e.button == LeftButton)
{
bool modified = false;
// clear old selections if no control key is pressed or if multi-select is off
if (!(e.sysKeys & Control) || !d_multiselect)
{
modified = clearAllSelections_impl();
}
Point localPos(screenToWindow(e.position));
if (getMetricsMode() == Relative)
{
localPos = relativeToAbsolute(localPos);
}
ListboxItem* item = getItemAtPoint(localPos);
if (item != NULL)
{
modified = true;
// select range or item, depending upon keys and last selected item
if (((e.sysKeys & Shift) && (d_lastSelected != NULL)) && d_multiselect)
{
selectRange(getItemIndex(item), getItemIndex(d_lastSelected));
}
else
{
item->setSelected(item->isSelected() ^ true);
}
// update last selected item
d_lastSelected = item->isSelected() ? item : NULL;
}
// fire event if needed
if (modified)
{
WindowEventArgs args(this);
onSelectionChanged(args);
}
e.handled = true;
}
}
示例2: setItemSelectState
/*************************************************************************
Set the select state of an attached ListboxItem.
*************************************************************************/
void Combobox::setItemSelectState(size_t item_index, bool state)
{
ComboDropList* droplist = getDropList();
ListboxItem* item = (droplist->getItemCount() > item_index) ?
droplist->getListboxItemFromIndex(item_index) :
0;
bool was_selected = (item && item->isSelected());
droplist->setItemSelectState(item_index, state);
itemSelectChangeTextUpdate(item, state, was_selected);
}