void ListBoxViewImpl::on_pointer_press(PointerEvent &e) { if (e.button() != PointerButton::left) return; last_selected_item = selected_item; int index = get_selection_index(e); listbox->set_selected_item(index); }
void ListBoxViewImpl::on_pointer_release(PointerEvent &e) { if (e.phase() != EventUIPhase::bubbling || e.button() != PointerButton::left) return; int index = get_selection_index(e); // Only allow click when mouse released over component if (index == selected_item) { if (func_selection_changed) func_selection_changed(); } else { listbox->set_selected_item(last_selected_item); } }