mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-09 15:12:35 -04:00
Scanner persisted freq file, TextField for current item (#1403)
* Don't truncate string passed to Text widget * Focus TextField on touch like other fields * TextField for current, save last opened freq file
This commit is contained in:
parent
4a1479957c
commit
f537c7896e
4 changed files with 58 additions and 36 deletions
|
@ -366,16 +366,17 @@ void Text::paint(Painter& painter) {
|
|||
const auto rect = screen_rect();
|
||||
auto s = has_focus() ? style().invert() : style();
|
||||
auto max_len = (unsigned)rect.width() / s.font.char_width();
|
||||
auto text_view = std::string_view{text};
|
||||
|
||||
painter.fill_rectangle(rect, s.background);
|
||||
|
||||
if (text.length() > max_len)
|
||||
text.resize(max_len);
|
||||
if (text_view.length() > max_len)
|
||||
text_view = text_view.substr(0, max_len);
|
||||
|
||||
painter.draw_string(
|
||||
rect.location(),
|
||||
s,
|
||||
text);
|
||||
text_view);
|
||||
}
|
||||
|
||||
/* Labels ****************************************************************/
|
||||
|
@ -1773,6 +1774,15 @@ bool TextField::on_encoder(EncoderEvent delta) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool TextField::on_touch(TouchEvent event) {
|
||||
if (event.type == TouchEvent::Type::Start) {
|
||||
focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* NumberField ***********************************************************/
|
||||
|
||||
NumberField::NumberField(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue