mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-11-26 22:56:24 -05:00
Touch for MenuView and Freqlist (#2829)
* freqman add touch support. solves #1919 * menuview touch support
This commit is contained in:
parent
e88ab44f49
commit
cbbd8103d3
5 changed files with 42 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue