Touch for MenuView and Freqlist (#2829)

* freqman add touch support. solves #1919

* menuview touch support
This commit is contained in:
Totoo 2025-10-17 15:59:35 +02:00 committed by GitHub
parent e88ab44f49
commit cbbd8103d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 42 additions and 1 deletions

View file

@ -93,6 +93,33 @@ void FreqManUIList::on_blur() {
set_dirty();
}
bool FreqManUIList::on_touch(const TouchEvent event) {
if (!db_ || db_->empty())
return false;
if (event.type == TouchEvent::Type::Start) {
focus();
set_dirty();
int16_t rel_y = event.point.y() - screen_rect().top();
size_t new_selected = rel_y / char_height;
if (new_selected + start_index_ >= db_->entry_count()) {
return true; // clicked, where there is no entry, skip it
}
// selected_index_ is the current
if (selected_index_ == new_selected) {
// already selected, trigger on_select
if (on_select) {
// on_select(new_selected); //causes strange behavior, not so confident to use it
}
return true;
} else {
// just change selection
selected_index_ = new_selected;
}
return true;
}
return true;
}
bool FreqManUIList::on_keyboard(const KeyboardEvent key) {
if (!db_ || db_->empty())
return false;