[][src]Module imgui_ext::input

input(...) docs.

Optional fields

  • label
  • step
  • step_fast
  • flags path to a function that returns the input flags that apply.
  • size Text box size (Applies to text input)
  • catch
  • map Applies a mapping function to &mut Self (see example).

Example

The input trait is implemented for numeric types (f32 and i32) and their corresponding array types of up to 8 elements.

#[derive(imgui_ext::Gui)]
struct Example {
    #[imgui(input)]
    input_0: f32,

    #[imgui(input)]
    input_1: [f32; 2],

    #[imgui(input(step = 4, step_fast = 42))]
    input_2: i32,
}

Result

result

Input flags

You can load input flags from a function:

use imgui::ImGuiInputTextFlags;

#[derive(imgui_ext::Gui)]
struct Example {
    #[imgui(input(flags = "Example::my_flags"))]
    n: f32,
}

impl Example {
    fn my_flags() -> ImGuiInputTextFlags {
        ImGuiInputTextFlags::Password
    }
}

Mapping

The attribute map points to a function (referenced by its path) that performs a map operation on the attribute:

// Note: Foo doesn't implement the ImGuiExt macro
struct Foo {
    inner: [f32; 4],
}

#[derive(imgui_ext::Gui)]
struct Bar {
    // Even though Foo is not compatible with the input()
    // annotation, its inner attribute does, therefore we
    // can map from one type to the other.
    #[imgui(input(map = "foo_to_array"))]
    foo: Foo,
}

fn foo_to_array(foo: &mut Foo) -> &mut [f32; 4] {
    &mut foo.inner
}

Structs

InputParams

Traits

Input