Skip to content

Commit 0599741

Browse files
committed
feat(UI): keep console input focused on other button presses
1 parent a1f2504 commit 0599741

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/UI/Screens/Console/ConsoleView.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ namespace UI
6868
m_shellToggle.setText(_("console.shell"));
6969
m_shellToggle.setFlag(LV_OBJ_FLAG_IGNORE_LAYOUT, true);
7070
m_shellToggle.setAlign(LV_ALIGN_TOP_RIGHT, -30, 20);
71-
m_shellToggle.setCheckedCallback([this](bool checked) { getPresenter()->enableShell(checked); });
71+
m_shellToggle.setCheckedCallback(
72+
[this](bool checked)
73+
{
74+
getPresenter()->enableShell(checked);
75+
focusInput();
76+
});
7277
m_shellToggle.setChecked(false);
7378
#endif
7479

@@ -90,6 +95,8 @@ namespace UI
9095
ConsoleView& view = *static_cast<ConsoleView*>(lv_event_get_user_data(e));
9196
bool show = !view.m_commandVisibility.hasState(LV_STATE_CHECKED);
9297
view.showCommandList(show, true);
98+
99+
view.focusInput();
93100
},
94101
this);
95102

@@ -235,6 +242,7 @@ namespace UI
235242
ConsoleView* view = static_cast<ConsoleView*>(lv_event_get_user_data(e));
236243
view->m_outputCont.scrollByBounded(0, -view->m_outputCont.getScrollBottom(), LV_ANIM_ON);
237244
view->m_input.sendEvent(LV_EVENT_READY, view);
245+
view->focusInput();
238246
}
239247

240248
void ConsoleView::onClearEvent(lv_event_t* e)
@@ -243,6 +251,7 @@ namespace UI
243251
UI_LOCK();
244252
ConsoleView* view = static_cast<ConsoleView*>(lv_event_get_user_data(e));
245253
view->clear();
254+
view->focusInput();
246255
}
247256

248257
#if 0
@@ -348,14 +357,21 @@ namespace UI
348357
m_commandList.getY() + 5);
349358
}
350359

360+
void ConsoleView::focusInput()
361+
{
362+
ZoneScoped;
363+
const bool kbVisible = m_kb.isVisible();
364+
lv_group_focus_obj(m_input.getRootPtr());
365+
m_kb.setVisible(kbVisible);
366+
}
367+
351368
void ConsoleView::onShow()
352369
{
353370
ZoneScoped;
354371
m_commandList.scrollToX(0, LV_ANIM_OFF);
355372
m_outputCont.scrollByBounded(0, -m_outputCont.getScrollBottom(), LV_ANIM_ON);
356-
lv_group_focus_obj(
357-
m_input.getRootPtr()); // make USB keyboards focus the input without the user having to tap it first
358373
m_kb.hide();
374+
focusInput();
359375
updateBtnPos();
360376
}
361377

src/UI/Screens/Console/ConsoleView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ namespace UI
7070
static void onKeyboardEvent(lv_event_t* e);
7171

7272
void updateBtnPos();
73+
void focusInput();
7374

7475
void onShow() override;
7576
void onHide() override;

0 commit comments

Comments
 (0)