On this page

ui_focus.h

Focus routing for component authors. Apps never include it, they use the focus calls in ui.h.

#include "isolenui/ui/ui_focus.h". The guide starts at Focus, scopes and modals.

Key claims

Explained in Focus, scopes and modals.

ui::focus_controlui::focus_claimsui::focus_keysui::key_claimui::claim_enterui::claim_spaceui::claim_xui::claim_yui::claim_endsui::claim_pagesui::claim_alt_y

Example

balance.cpp
#include "isolenui/ui/ui.h"
#include "isolenui/ui/ui_focus.h"

// a component that tab reaches and that owns left and right while focused
static bool balance(ui::ctx* u, const char* label, float* pan)
{
    ui::key(u, label);
    bool changed = false;
    ui_box(u, ui::row().height(28.0f).width(160.0f).as(ui::role_slider))
    {
        ui::focus_control(u, 0, ui::claim_x);
        const uint32_t* keys = nullptr;
        const uint8_t* mods = nullptr;
        const uint32_t n = ui::focus_keys(u, ui::last_id(u), &keys, &mods);
        for (uint32_t i = 0; i < n; ++i) {
            const float step = keys[i] == ui::vk::left ? -0.1f : keys[i] == ui::vk::right ? 0.1f : 0.0f;
            if (step != 0.0f) {
                *pan = *pan + step < -1.0f ? -1.0f : (*pan + step > 1.0f ? 1.0f : *pan + step);
                changed = true;
            }
        }
        ui::textf(u, ui::caption(u), "%s %.1f", label, double(*pan));
    }
    return changed;
}

Last updated 23 October 2026