Allow clipboard access in Widget::on_event

This commit is contained in:
Héctor Ramón Jiménez 2019-12-18 07:45:49 +01:00
parent 0f2e20f5e5
commit a14b39555e
20 changed files with 89 additions and 26 deletions

View file

@ -6,8 +6,8 @@
//! [`State`]: struct.State.html
use crate::{
input::{mouse, ButtonState},
layout, Background, Element, Event, Hasher, Layout, Length, Point,
Rectangle, Widget,
layout, Background, Clipboard, Element, Event, Hasher, Layout, Length,
Point, Rectangle, Widget,
};
use std::hash::Hash;
@ -192,6 +192,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
_renderer: &Renderer,
_clipboard: Option<&dyn Clipboard>,
) {
match event {
Event::Mouse(mouse::Event::Input {

View file

@ -3,7 +3,7 @@ use std::hash::Hash;
use crate::{
input::{mouse, ButtonState},
layout, row, text, Align, Color, Element, Event, Font, Hasher,
layout, row, text, Align, Clipboard, Color, Element, Event, Font, Hasher,
HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text,
VerticalAlignment, Widget,
};
@ -114,6 +114,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
_renderer: &Renderer,
_clipboard: Option<&dyn Clipboard>,
) {
match event {
Event::Mouse(mouse::Event::Input {

View file

@ -2,7 +2,8 @@
use std::hash::Hash;
use crate::{
layout, Align, Element, Event, Hasher, Layout, Length, Point, Widget,
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Widget,
};
use std::u32;
@ -153,6 +154,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>,
) {
self.children.iter_mut().zip(layout.children()).for_each(
|(child, layout)| {
@ -162,6 +164,7 @@ where
cursor_position,
messages,
renderer,
clipboard,
)
},
);

View file

@ -2,7 +2,8 @@
use std::hash::Hash;
use crate::{
layout, Align, Element, Event, Hasher, Layout, Length, Point, Widget,
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Widget,
};
use std::u32;
@ -131,6 +132,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>,
) {
self.content.widget.on_event(
event,
@ -138,6 +140,7 @@ where
cursor_position,
messages,
renderer,
clipboard,
)
}

View file

@ -1,7 +1,7 @@
//! Create choices using radio buttons.
use crate::{
input::{mouse, ButtonState},
layout, row, text, Align, Color, Element, Event, Font, Hasher,
layout, row, text, Align, Clipboard, Color, Element, Event, Font, Hasher,
HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text,
VerticalAlignment, Widget,
};
@ -113,6 +113,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
_renderer: &Renderer,
_clipboard: Option<&dyn Clipboard>,
) {
match event {
Event::Mouse(mouse::Event::Input {

View file

@ -2,7 +2,8 @@
use std::hash::Hash;
use crate::{
layout, Align, Element, Event, Hasher, Layout, Length, Point, Widget,
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Widget,
};
use std::u32;
@ -154,6 +155,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>,
) {
self.children.iter_mut().zip(layout.children()).for_each(
|(child, layout)| {
@ -163,6 +165,7 @@ where
cursor_position,
messages,
renderer,
clipboard,
)
},
);

View file

@ -2,8 +2,8 @@
use crate::{
column,
input::{mouse, ButtonState},
layout, Align, Column, Element, Event, Hasher, Layout, Length, Point,
Rectangle, Size, Widget,
layout, Align, Clipboard, Column, Element, Event, Hasher, Layout, Length,
Point, Rectangle, Size, Widget,
};
use std::{f32, hash::Hash, u32};
@ -143,6 +143,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>,
) {
let bounds = layout.bounds();
let is_mouse_over = bounds.contains(cursor_position);
@ -247,6 +248,7 @@ where
cursor_position,
messages,
renderer,
clipboard,
)
}

View file

@ -6,8 +6,8 @@
//! [`State`]: struct.State.html
use crate::{
input::{mouse, ButtonState},
layout, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size,
Widget,
layout, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Rectangle, Size, Widget,
};
use std::{hash::Hash, ops::RangeInclusive};
@ -133,6 +133,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
_renderer: &Renderer,
_clipboard: Option<&dyn Clipboard>,
) {
let mut change = || {
let bounds = layout.bounds();

View file

@ -6,8 +6,8 @@
//! [`State`]: struct.State.html
use crate::{
input::{keyboard, mouse, ButtonState},
layout, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size,
Widget,
layout, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Rectangle, Size, Widget,
};
use unicode_segmentation::UnicodeSegmentation;
@ -172,6 +172,7 @@ where
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
_clipboard: Option<&dyn Clipboard>,
) {
match event {
Event::Mouse(mouse::Event::Input {