This article includes details on how MuditaOS widgets are rendered and how the GUI handles key pressing.
gui::Itemgui::Item::buildDrawList in each gui::Item - uses gui::Items tree to builds draw commandsapp::Application::refreshWindow in app::Application - triggers update on display on message: gui::AppRefreshMessage (final draw on screen done with: app::Application::render)gui::Item callbacks, which are in [callbacks](@ref callbacks "Item callbacks"), orgui::Item virtual functions, [callback functions](@ref callbackCallers) When overriding please mind that you might want to use ancestor function inside too to i.e. not loose key presses etc.gui::Item are able to handle keyPresses via gui::InputEventgui::Item are able to traverse down on their gui::Item::children and know which child has gui::Item::focusItem at the timePlease see app::Application, app::manager::ApplicationManager for detailed information on how messages are handled between both. This is just general documentation.
These actions are done on a chained bus request between: app::Application, app::manager::ApplicationManager and sapm::EventWorker
All of these are asynchronous and there is little state machine maintenance.
app::Application has it's own state which is managed both in application and in manager (via setters and getters)sapm::ApplicationManager has it's own state which tells what exactly it's processing right nowNote: All app::Application:
app::Application::createUserInterfaceapp::Application::DataReceivedHandler first to parent function call to properly handle bus messagesgui::AppWindowNote: When it comes to gui::AppWindow:
gui::AppWindow::buildInterface has to call parent build interface first. Otherwise elements for child won't be created and it will crashgui::AppWindow::onInput has to call parent onInput, otherwise handling key presses will failgui::AppWindow will try to return to previous window or application on backgui::Item Key Press handlingbsp handles key press on I2C IRQ and sends Event to event worker on naked FreeRTOS pipe (on target RT1051, on Linux gtk does that)EventWorker worker of EventService:
gui::InputEvent with RawKey or gui::KeyInputSimpleTranslationgui::Item::onInput)gui::KeyInputMappedTranslation + gui::InputMode and process key press however they wantThere are at least 3 ways to handle key press, listed in order of execution:
gui::Item::onInput - if not redefined calls inputCallback; if handled here, other calls wont be calledgui::Item::inputCallback - handles any keygui::Item::activatedCallback - handles Enter key onlygui::Item::itemNavigation - handles up,down,left,right if next/previous elements are added for an itemNote: return True when any of callbacks ends processing the whole Items tree
There are 2 set of parameters for key press:
gui::InputEvent::State - state of key (pressed, released, long released). In general applications handle key releases not pressesgui::KeyCode - initially parsed key codegui::RawKey - raw key code, to be processed in widget based on event i.e. translate pressing key 1 3 times into C in gui::Text mode ABC1 3 times to get C, press 1 4 times to get A, etc.InputMode, right now there are following InputMode::Modes: [ABC, abc, digit, phone]gui::InputMode are changed in regards of language settingsphonecp image/assets/profiles/template.kprof image/assets/profiles/phone.kprof"common_kbd_phone": "phone" to at least image/assets/lang/lang_en.json if it will differ per language, prepare one kprof file per languagegui::InputMode
InputMode::Mode enum i.e. InputMode::Mode::phoneInputMode.cpp (same as with other enums)UITestWindow.cppNow you can use InputMode::Mode::phone translation in gui::Text widget.
This means gui::Text will automatically change text on key press for you, same as in modes InputMode::Mode::phone etc.