Add OptionsField event for on_focus.

TODO: So poorly named! Should be on_focus, but requires sweeping changes. Ugh.
This commit is contained in:
Jared Boone 2016-02-02 13:41:11 -08:00
parent fece0a5e1b
commit be8c1307e2
2 changed files with 8 additions and 0 deletions

View File

@ -473,6 +473,12 @@ void OptionsField::paint(Painter& painter) {
}
}
void OptionsField::on_focus() {
if( on_show_options ) {
on_show_options();
}
}
bool OptionsField::on_encoder(const EncoderEvent delta) {
set_selected_index(selected_index() + delta);
return true;

View File

@ -226,6 +226,7 @@ public:
using options_t = std::vector<option_t>;
std::function<void(size_t, value_t)> on_change;
std::function<void(void)> on_show_options;
OptionsField(Point parent_pos, size_t length, options_t options);
@ -236,6 +237,7 @@ public:
void paint(Painter& painter) override;
void on_focus() override;
bool on_encoder(const EncoderEvent delta) override;
bool on_touch(const TouchEvent event) override;