Avoid continuous redrawing events when moving mouse on Edit > Preferences listbox of sections

This commit is contained in:
David Capello 2021-06-08 20:34:57 -03:00
parent ca252f9f02
commit a0bea17bc0

View File

@ -91,6 +91,8 @@ Widget* ListBox::getChildByIndex(int index)
void ListBox::selectChild(Widget* item, Message* msg)
{
bool didChange = false;
int itemIndex = getChildIndex(item);
m_lastSelectedIndex = itemIndex;
@ -107,7 +109,10 @@ void ListBox::selectChild(Widget* item, Message* msg)
bool state = child->isSelected();
if (msg && !msg->ctrlPressed() && !msg->cmdPressed())
state = false;
m_states[i] = state;
if (m_states[i] != state) {
didChange = true;
m_states[i] = state;
}
++i;
}
}
@ -130,8 +135,10 @@ void ListBox::selectChild(Widget* item, Message* msg)
newState = (child == item);
}
if (child->isSelected() != newState)
if (child->isSelected() != newState) {
didChange = true;
child->setSelected(newState);
}
++i;
}
@ -139,7 +146,8 @@ void ListBox::selectChild(Widget* item, Message* msg)
if (item)
makeChildVisible(item);
onChange();
if (didChange)
onChange();
}
void ListBox::selectIndex(int index, Message* msg)