January 2018
Beginner to intermediate
454 pages
10h 8m
English
Let's now see how to handle the SongStarted message. To do so, we use a syntax similar to the one for handling gtk events. The message is on the left side of => while the handler is on the right side of it:
#[widget] impl Widget for App { // … view! { // … #[name="playlist"] Playlist { SongStarted(ref pixbuf) => Started(pixbuf.clone()), } } }
We can see here that when we receive the SongStarted message from the playlist, we emit the Started message on the same widget (App). We needed to use ref and then clone() the value contained in the message here because we do not own the message. Indeed, multiple widgets can listen to the same message, the widget that emitted the message and its parent. Before we handle ...
Read now
Unlock full access