January 2018
Beginner to intermediate
454 pages
10h 8m
English
Sending a message to another widget with emit() is a bit verbose, so relm provides syntactic sugar for this case. Let's send a message to the playlist when the user clicks the remove button:
gtk::ToolButton { icon_widget: &new_icon("remove"), clicked => playlist@RemoveSong, }
Here, we used the @ syntax to specify that the message will be sent to another widget. The part before the @ is the receiver widget, while the part after this character is the message. So, this code means that whenever the user clicks the remove button, send the RemoveSong message to the playlist widget.
Let's handle this message in the Paylist::update() method:
#[widget] impl Widget for Playlist { fn update(&mut ...