Skip to content

Commit c1f70f1

Browse files
authored
Merge pull request #773 from hecrj/feature/clipboard-access-in-update
Clipboard access in `Application::update`
2 parents 7eb5127 + 7da3fb1 commit c1f70f1

21 files changed

Lines changed: 170 additions & 58 deletions

File tree

examples/clock/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use iced::{
22
canvas::{self, Cache, Canvas, Cursor, Geometry, LineCap, Path, Stroke},
3-
executor, time, Application, Color, Command, Container, Element, Length,
4-
Point, Rectangle, Settings, Subscription, Vector,
3+
executor, time, Application, Clipboard, Color, Command, Container, Element,
4+
Length, Point, Rectangle, Settings, Subscription, Vector,
55
};
66

77
pub fn main() -> iced::Result {
@@ -40,7 +40,11 @@ impl Application for Clock {
4040
String::from("Clock - Iced")
4141
}
4242

43-
fn update(&mut self, message: Message) -> Command<Message> {
43+
fn update(
44+
&mut self,
45+
message: Message,
46+
_clipboard: &mut Clipboard,
47+
) -> Command<Message> {
4448
match message {
4549
Message::Tick(local_time) => {
4650
let now = local_time;

examples/download_progress/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use iced::{
2-
button, executor, Align, Application, Button, Column, Command, Container,
3-
Element, Length, ProgressBar, Settings, Subscription, Text,
2+
button, executor, Align, Application, Button, Clipboard, Column, Command,
3+
Container, Element, Length, ProgressBar, Settings, Subscription, Text,
44
};
55

66
mod download;
@@ -43,7 +43,11 @@ impl Application for Example {
4343
String::from("Download progress - Iced")
4444
}
4545

46-
fn update(&mut self, message: Message) -> Command<Message> {
46+
fn update(
47+
&mut self,
48+
message: Message,
49+
_clipboard: &mut Clipboard,
50+
) -> Command<Message> {
4751
match message {
4852
Message::Add => {
4953
self.last_id = self.last_id + 1;

examples/events/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use iced::{
2-
executor, Align, Application, Checkbox, Column, Command, Container,
3-
Element, Length, Settings, Subscription, Text,
2+
executor, Align, Application, Checkbox, Clipboard, Column, Command,
3+
Container, Element, Length, Settings, Subscription, Text,
44
};
55

66
pub fn main() -> iced::Result {
@@ -32,7 +32,11 @@ impl Application for Events {
3232
String::from("Events - Iced")
3333
}
3434

35-
fn update(&mut self, message: Message) -> Command<Message> {
35+
fn update(
36+
&mut self,
37+
message: Message,
38+
_clipboard: &mut Clipboard,
39+
) -> Command<Message> {
3640
match message {
3741
Message::EventOccurred(event) => {
3842
self.last.push(event);

examples/game_of_life/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use iced::pick_list::{self, PickList};
1010
use iced::slider::{self, Slider};
1111
use iced::time;
1212
use iced::{
13-
Align, Application, Checkbox, Column, Command, Container, Element, Length,
14-
Row, Settings, Subscription, Text,
13+
Align, Application, Checkbox, Clipboard, Column, Command, Container,
14+
Element, Length, Row, Settings, Subscription, Text,
1515
};
1616
use preset::Preset;
1717
use std::time::{Duration, Instant};
@@ -65,7 +65,11 @@ impl Application for GameOfLife {
6565
String::from("Game of Life - Iced")
6666
}
6767

68-
fn update(&mut self, message: Message) -> Command<Message> {
68+
fn update(
69+
&mut self,
70+
message: Message,
71+
_clipboard: &mut Clipboard,
72+
) -> Command<Message> {
6973
match message {
7074
Message::Grid(message, version) => {
7175
if version == self.version {

examples/integration/src/controls.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use iced_wgpu::Renderer;
22
use iced_winit::{
3-
slider, Align, Color, Column, Command, Element, Length, Program, Row,
4-
Slider, Text,
3+
slider, Align, Clipboard, Color, Column, Command, Element, Length, Program,
4+
Row, Slider, Text,
55
};
66

77
pub struct Controls {
@@ -30,8 +30,13 @@ impl Controls {
3030
impl Program for Controls {
3131
type Renderer = Renderer;
3232
type Message = Message;
33+
type Clipboard = Clipboard;
3334

34-
fn update(&mut self, message: Message) -> Command<Message> {
35+
fn update(
36+
&mut self,
37+
message: Message,
38+
_clipboard: &mut Clipboard,
39+
) -> Command<Message> {
3540
match message {
3641
Message::BackgroundColorChanged(color) => {
3742
self.background_color = color;

examples/pane_grid/src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use iced::{
22
button, executor, keyboard, pane_grid, scrollable, Align, Application,
3-
Button, Color, Column, Command, Container, Element, HorizontalAlignment,
4-
Length, PaneGrid, Row, Scrollable, Settings, Subscription, Text,
3+
Button, Clipboard, Color, Column, Command, Container, Element,
4+
HorizontalAlignment, Length, PaneGrid, Row, Scrollable, Settings,
5+
Subscription, Text,
56
};
67
use iced_native::{event, subscription, Event};
78

@@ -49,7 +50,11 @@ impl Application for Example {
4950
String::from("Pane grid - Iced")
5051
}
5152

52-
fn update(&mut self, message: Message) -> Command<Message> {
53+
fn update(
54+
&mut self,
55+
message: Message,
56+
_clipboard: &mut Clipboard,
57+
) -> Command<Message> {
5358
match message {
5459
Message::Split(axis, pane) => {
5560
let result = self.panes.split(

examples/pokedex/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use iced::{
2-
button, futures, image, Align, Application, Button, Column, Command,
3-
Container, Element, Length, Row, Settings, Text,
2+
button, futures, image, Align, Application, Button, Clipboard, Column,
3+
Command, Container, Element, Length, Row, Settings, Text,
44
};
55

66
pub fn main() -> iced::Result {
@@ -48,7 +48,11 @@ impl Application for Pokedex {
4848
format!("{} - Pokédex", subtitle)
4949
}
5050

51-
fn update(&mut self, message: Message) -> Command<Message> {
51+
fn update(
52+
&mut self,
53+
message: Message,
54+
_clipboard: &mut Clipboard,
55+
) -> Command<Message> {
5256
match message {
5357
Message::PokemonFound(Ok(pokemon)) => {
5458
*self = Pokedex::Loaded {

examples/solar_system/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
//! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system
99
use iced::{
1010
canvas::{self, Cursor, Path, Stroke},
11-
executor, time, window, Application, Canvas, Color, Command, Element,
12-
Length, Point, Rectangle, Settings, Size, Subscription, Vector,
11+
executor, time, window, Application, Canvas, Clipboard, Color, Command,
12+
Element, Length, Point, Rectangle, Settings, Size, Subscription, Vector,
1313
};
1414

1515
use std::time::Instant;
@@ -48,7 +48,11 @@ impl Application for SolarSystem {
4848
String::from("Solar system - Iced")
4949
}
5050

51-
fn update(&mut self, message: Message) -> Command<Message> {
51+
fn update(
52+
&mut self,
53+
message: Message,
54+
_clipboard: &mut Clipboard,
55+
) -> Command<Message> {
5256
match message {
5357
Message::Tick(instant) => {
5458
self.state.update(instant);

examples/stopwatch/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use iced::{
2-
button, executor, time, Align, Application, Button, Column, Command,
3-
Container, Element, HorizontalAlignment, Length, Row, Settings,
2+
button, executor, time, Align, Application, Button, Clipboard, Column,
3+
Command, Container, Element, HorizontalAlignment, Length, Row, Settings,
44
Subscription, Text,
55
};
66
use std::time::{Duration, Instant};
@@ -49,7 +49,11 @@ impl Application for Stopwatch {
4949
String::from("Stopwatch - Iced")
5050
}
5151

52-
fn update(&mut self, message: Message) -> Command<Message> {
52+
fn update(
53+
&mut self,
54+
message: Message,
55+
_clipboard: &mut Clipboard,
56+
) -> Command<Message> {
5357
match message {
5458
Message::Toggle => match self.state {
5559
State::Idle => {

examples/todos/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use iced::{
22
button, scrollable, text_input, Align, Application, Button, Checkbox,
3-
Column, Command, Container, Element, Font, HorizontalAlignment, Length,
4-
Row, Scrollable, Settings, Text, TextInput,
3+
Clipboard, Column, Command, Container, Element, Font, HorizontalAlignment,
4+
Length, Row, Scrollable, Settings, Text, TextInput,
55
};
66
use serde::{Deserialize, Serialize};
77

@@ -58,7 +58,11 @@ impl Application for Todos {
5858
format!("Todos{} - Iced", if dirty { "*" } else { "" })
5959
}
6060

61-
fn update(&mut self, message: Message) -> Command<Message> {
61+
fn update(
62+
&mut self,
63+
message: Message,
64+
_clipboard: &mut Clipboard,
65+
) -> Command<Message> {
6266
match self {
6367
Todos::Loading => {
6468
match message {

0 commit comments

Comments
 (0)