[][src]Module imgui_ext::nested

nested(...) docs (used to build nested UIs).

Types that #[derive(ImGuiExt)] can be nested.

Optional fields

  • catch

Example

use imgui::{ImString, ImGuiInputTextFlags};
use imgui_ext::ImGuiExt;

#[derive(ImGuiExt)]
struct Form {
    #[imgui(input)]
    user: ImString,
    #[imgui(
        input(flags = "passwd_flags"),
        button(label = "Login", catch = "login_btn"),
    )]
    passwd: ImString,
}

fn passwd_flags() -> ImGuiInputTextFlags {
    ImGuiInputTextFlags::Password
}

#[derive(ImGuiExt)]
struct Example {
    #[imgui(nested, separator)]
    login_form: Form,
    #[imgui(checkbox(label = "Remember login?"))]
    remember: bool,
}

Result

Nested input events

You can access input events from nested UIs:

This example is not tested
// initialize imgui (ui) ...

let mut example = Example { ... };
let events: Events<Example> = ui.imgui_ext(&mut example);

if events.login_form().login_btn() {
    validate_user(
        &example.login_form.user,
        &example.login_form.passwd,
    )
}