[][src]Macro orbtk_api::widget

macro_rules! widget {
    ( $(#[$widget_doc:meta])* $widget:ident $(<$state:ident>)* $(: $( $handler:ident ),*)*
            $( { $($(#[$prop_doc:meta])* $property:ident: $property_type:tt ),*
                $( attached_properties: { $($(#[$att_prop_doc:meta])* $att_property:ident: $att_property_type:tt ),* } )*
             } )* ) => { ... };
}

Defines a new type of Widget with its properties and event handlers. Widgets defined by this macro can be instantiated by calling the new() method. Inherits default properties from a base widget. Implements the Widget trait automatically. Also the struct serves as a builder of the builder pattern.

Syntax:

widget!(MyWidgetName<MyWidgetStateStruct>: Handler1, Handler2, Handler3 {
    property_name_1: PropertyType1,
    property_name_2: PropertyType2
});

Examples

Creates a widget named PersonWidget with three properties, without handlers, and with a state struct called WidgetState.

widget!(PersonWidget<WidgetState> {
    name: String16,
    age: usize,
    average: f64
});