From a0bea17bc00b10db0689dceb40711a21f8700a7e Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 8 Jun 2021 20:34:57 -0300 Subject: [PATCH] Avoid continuous redrawing events when moving mouse on Edit > Preferences listbox of sections --- src/ui/listbox.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ui/listbox.cpp b/src/ui/listbox.cpp index 88962d187..28a476550 100644 --- a/src/ui/listbox.cpp +++ b/src/ui/listbox.cpp @@ -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)