[][src]Struct mogwai::gizmo::Gizmo

pub struct Gizmo<T: JsCast> { /* fields omitted */ }

A widget that may contain a bundled network of html elements, callback closures and receivers.

Implementations

impl<T: JsCast + AsRef<EventTarget>> Gizmo<T>[src]

pub fn tx_on(self, ev_name: &str, tx: Transmitter<Event>) -> Gizmo<T>[src]

Sends an event into the given transmitter when the given dom event happens.

pub fn tx_on_window(self, ev_name: &str, tx: Transmitter<Event>) -> Gizmo<T>[src]

Sends an event into the given transmitter when the given dom event happens on window.

pub fn tx_on_document(self, ev_name: &str, tx: Transmitter<Event>) -> Gizmo<T>[src]

Sends an event into the given transmitter when the given dom event happens.

impl<T: JsCast + AsRef<Node>> Gizmo<T>[src]

pub fn text(self, s: &str) -> Gizmo<T>[src]

Create a text node and insert it into the Gizmo being built.

pub fn rx_text(self, init: &str, rx: Receiver<String>) -> Gizmo<T>[src]

Create a text node that changes its text to anything that is sent on the given receiver and insert it into the Gizmo being built.

pub fn with<Child>(self, child: Child) -> Gizmo<T> where
    Child: SubGizmo
[src]

Append a child that implements SubGizmo to this Gizmo.

impl<T: JsCast + AsRef<Element>> Gizmo<T>[src]

pub fn attribute(self, name: &str, value: &str) -> Gizmo<T>[src]

Create a static attribute on the Gizmo being built.

pub fn boolean_attribute(self, name: &str, condition: bool) -> Gizmo<T>[src]

If condition is true, create a static boolean attribute on the Gizmo being built.

For background on condition See https://github.com/schell/mogwai/issues/19

pub fn class(self, value: &str) -> Gizmo<T>[src]

Create a class attribute on the Gizmo being built.

This represents all the classes for this gizmo. If you'd like to specify more than one class call this as:

extern crate mogwai;
use mogwai::prelude::*;

let gizmo_the_long_way =
  Gizmo::element("div")
  .downcast::<HtmlElement>().ok().unwrap()
  .class("class1 class2 class3 etc");

let gizmo =
  div()
  .class("class1 class2 class3 etc");

pub fn id(self, value: &str) -> Gizmo<T>[src]

Create an id attribute on the Gizmo being built.

pub fn rx_attribute(
    self,
    name: &str,
    init: Option<&str>,
    rx: Receiver<Option<String>>
) -> Gizmo<T>
[src]

Create an attribute on the Gizmo being built that changes its value every time the given receiver receives a message. If the receiver receives None it will respond by removing the attribute until it receives Some(...).

pub fn rx_boolean_attribute(
    self,
    name: &str,
    init: bool,
    rx: Receiver<bool>
) -> Gizmo<T>
[src]

Create a boolean attribute on the Gizmo being built that changes its value every time the given receiver receives a message. If the receiver receives None it will respond by removing the attribute until it receives Some(...).

pub fn rx_class(self, init: &str, rx: Receiver<String>) -> Gizmo<T>[src]

Create a class attribute on the Gizmo being built that changes its value every time the given receiver receives a message.

impl<T: JsCast + AsRef<HtmlElement>> Gizmo<T>[src]

pub fn style(self, name: &str, value: &str) -> Gizmo<T>[src]

Set a CSS property in the style attribute of the Gizmo being built.

pub fn rx_style(self, s: &str, init: &str, rx: Receiver<String>) -> Gizmo<T>[src]

Set a CSS property in the style attribute of the Gizmo being built that updates its value every time a message is received on the given Receiver.

impl<T: JsCast + AsRef<HtmlInputElement>> Gizmo<T>[src]

pub fn value(self, s: &str) -> Gizmo<T>[src]

Set the value of the Gizmo input.

pub fn rx_value(self, init: &str, rx: Receiver<String>) -> Gizmo<T>[src]

Set the value of the Gizmo input that updates every time a message is received on the given Receiver.

pub fn checked(self, checked: bool) -> Gizmo<T>[src]

Set the checked value of the Gizmo input.

pub fn rx_checked(self, checked: bool, rx: Receiver<bool>) -> Gizmo<T>[src]

Set the value of the Gizmo input that updates every time a message is received on the given Receiver.

impl<T: JsCast> Gizmo<T>[src]

pub fn wrapping(element: T) -> Gizmo<T>[src]

Create a new Gizmo wrapping a T that can be dereferenced to a Node.

impl<T: JsCast + Clone> Gizmo<T>[src]

pub fn upcast<D>(self) -> Gizmo<D> where
    T: AsRef<D>,
    D: JsCast
[src]

Cast the given Gizmo to contain the inner DOM node of another type. That type must be dereferencable from the given Gizmo.

pub fn downcast<To: JsCast + AsRef<Node>>(self) -> Result<Gizmo<To>, Gizmo<T>>[src]

Attempt to downcast the inner element.

impl<T: JsCast + 'static> Gizmo<T>[src]

pub fn forget(self) -> Result<(), JsValue>[src]

Run this gizmo forever without appending it to anything.

impl<T: JsCast + AsRef<Node> + Clone + 'static> Gizmo<T>[src]

pub fn run_in_container(self, container: &Node) -> Result<(), JsValue>[src]

Run this gizmo in a parent container forever, never dropping it.

pub fn run(self) -> Result<(), JsValue>[src]

Run this gizmo in the document body forever, never dropping it.

pub fn tx_post_build(self, tx: Transmitter<T>) -> Gizmo<T>[src]

After the gizmo is built, send a clone of T on the given transmitter. This allows you to construct component behaviors that operate on the T directly, while still keeping the Gizmo in its place within your view function. For example, you may want to use input.focus() within the update function of your component. This method allows you to store the input's HtmlInputElement once it is built.

impl Gizmo<Element>[src]

pub fn element(tag: &str) -> Self[src]

Create a new gizmo with the given element tag.

This example is not tested
Gizmo::element("div")

pub fn element_ns(tag: &str, ns: &str) -> Self[src]

Create a new gizmo with the given element tag.

This example is not tested
Gizmo::element("div")

pub fn from_element_by_id(id: &str) -> Option<Gizmo<Element>>[src]

Create a new Gizmo from an existing Element with the given id. Returns None if it cannot be found.

Trait Implementations

impl<T, S> AsRef<S> for Gizmo<T> where
    T: JsCast + AsRef<S>,
    S: JsCast
[src]

impl<T: JsCast + Clone> Clone for Gizmo<T>[src]

impl<T: JsCast> Deref for Gizmo<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: JsCast> Drop for Gizmo<T>[src]

Gizmo's Drop implementation insures that responders no longer attempt to update the gizmo. It also removes its element from the DOM.

impl<T, D> From<T> for Gizmo<D> where
    T: Component,
    T::DomNode: AsRef<D>,
    D: JsCast + 'static, 
[src]

impl<T: JsCast + AsRef<Node> + Clone> SubGizmo for Gizmo<T>[src]

impl<'_, T: JsCast + AsRef<Node> + Clone> SubGizmo for &'_ Gizmo<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Gizmo<T>

impl<T> !Send for Gizmo<T>

impl<T> !Sync for Gizmo<T>

impl<T> Unpin for Gizmo<T> where
    T: Unpin

impl<T> !UnwindSafe for Gizmo<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubGizmo for T where
    T: Component,
    <T as Component>::DomNode: AsRef<Node>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.