Add support for PageUp/PageDown/Home/End buttons. (#242)

See:
https://github.com/ArthurSonzogni/FTXUI/issues/241
This commit is contained in:
Arthur Sonzogni 2021-10-20 21:15:40 +02:00 committed by GitHub
parent 4188ee2c04
commit 313ce9c35f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -101,6 +101,22 @@ class VerticalContainer : public ContainerBase {
MoveSelector(-1);
if (event == Event::ArrowDown || event == Event::Character('j'))
MoveSelector(+1);
if (event == Event::PageUp) {
for(int i = 0; i<box_.y_max - box_.y_min; ++i)
MoveSelector(-1);
}
if (event == Event::PageDown) {
for(int i = 0; i<box_.y_max - box_.y_min; ++i)
MoveSelector(1);
}
if (event == Event::Home) {
for (size_t i = 0; i < children_.size(); ++i)
MoveSelector(-1);
}
if (event == Event::End) {
for (size_t i = 0; i < children_.size(); ++i)
MoveSelector(1);
}
if (event == Event::Tab && children_.size())
MoveSelectorWrap(+1);
if (event == Event::TabReverse && children_.size())

View File

@ -61,6 +61,14 @@ class MenuBase : public ComponentBase {
(*selected_)--;
if (event == Event::ArrowDown || event == Event::Character('j'))
(*selected_)++;
if (event == Event::PageUp)
(*selected_) -= box_.y_max - box_.y_min;
if (event == Event::PageDown)
(*selected_) += box_.y_max - box_.y_min;
if (event == Event::Home)
(*selected_) = 0;
if (event == Event::End)
(*selected_) = entries_.size() - 1;
if (event == Event::Tab && entries_.size())
*selected_ = (*selected_ + 1) % entries_.size();
if (event == Event::TabReverse && entries_.size())

View File

@ -79,6 +79,14 @@ class RadioboxBase : public ComponentBase {
(hovered_)--;
if (event == Event::ArrowDown || event == Event::Character('j'))
(hovered_)++;
if (event == Event::PageUp)
(hovered_) -= box_.y_max - box_.y_min;
if (event == Event::PageDown)
(hovered_) += box_.y_max - box_.y_min;
if (event == Event::Home)
(hovered_) = 0;
if (event == Event::End)
(hovered_) = entries_.size() - 1;
if (event == Event::Tab && entries_.size())
hovered_ = (hovered_ + 1) % entries_.size();
if (event == Event::TabReverse && entries_.size())