fix(text_input): add alt_clipboard bindings
This commit is contained in:
parent
8df1858e5d
commit
e7f278d17f
3 changed files with 40 additions and 21 deletions
2
iced
2
iced
|
|
@ -1 +1 @@
|
||||||
Subproject commit 62b90179a298b06ed3e88362e08ef47f8557da27
|
Subproject commit 7afd9ee0f83cfd1a4e9f9b56cf0f365e5ae60347
|
||||||
|
|
@ -17,9 +17,13 @@ pub struct ListButton<'a, Message> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a DndSource, wrapping an element
|
/// Builds a DndSource, wrapping an element
|
||||||
pub type DndSourceBuilder<'a, Message> = dyn FnOnce(Element<'a, Message>) -> DndSource<'a, Message, Box<dyn iced::clipboard::mime::AsMimeTypes + Send>>;
|
pub type DndSourceBuilder<'a, Message> =
|
||||||
|
dyn FnOnce(
|
||||||
|
Element<'a, Message>,
|
||||||
|
) -> DndSource<'a, Message, Box<dyn iced::clipboard::mime::AsMimeTypes + Send>>;
|
||||||
/// Builds a DndDestination, wrapping an element
|
/// Builds a DndDestination, wrapping an element
|
||||||
pub type DndDestinationBuilder<'a, Message> = dyn FnOnce(Element<'a, Message>) -> DndDestination<'a, Message>;
|
pub type DndDestinationBuilder<'a, Message> =
|
||||||
|
dyn FnOnce(Element<'a, Message>) -> DndDestination<'a, Message>;
|
||||||
|
|
||||||
/// Creates a [`ListButton`] with the given content.
|
/// Creates a [`ListButton`] with the given content.
|
||||||
pub fn button<'a, Message>(content: impl Into<Element<'a, Message>>) -> ListButton<'a, Message> {
|
pub fn button<'a, Message>(content: impl Into<Element<'a, Message>>) -> ListButton<'a, Message> {
|
||||||
|
|
@ -53,7 +57,10 @@ impl<'a, Message: 'static> ListButton<'a, Message> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_dnd_destination(mut self, builder: Box<DndDestinationBuilder<'a, Message>>) -> Self {
|
pub fn with_dnd_destination(
|
||||||
|
mut self,
|
||||||
|
builder: Box<DndDestinationBuilder<'a, Message>>,
|
||||||
|
) -> Self {
|
||||||
self.dnd_destination_builder = Some(builder);
|
self.dnd_destination_builder = Some(builder);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -197,8 +204,7 @@ impl<'a, Message: Clone + 'static> ListColumn<'a, Message> {
|
||||||
dnd_source_builder,
|
dnd_source_builder,
|
||||||
dnd_destination_builder,
|
dnd_destination_builder,
|
||||||
}) => {
|
}) => {
|
||||||
let mut button: Element<'a, Message> =
|
let mut button: Element<'a, Message> = content_row(content)
|
||||||
content_row(content)
|
|
||||||
.apply(button::custom)
|
.apply(button::custom)
|
||||||
.padding(item_padding)
|
.padding(item_padding)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
|
|
@ -219,7 +225,7 @@ impl<'a, Message: Clone + 'static> ListColumn<'a, Message> {
|
||||||
}
|
}
|
||||||
|
|
||||||
col.push(button)
|
col.push(button)
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1821,9 +1821,22 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
focus.updated_at = Instant::now();
|
focus.updated_at = Instant::now();
|
||||||
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
||||||
|
|
||||||
// Check if Ctrl/Command+A/C/V/X was pressed.
|
// Ctrl/Command+A/C/V/X, plus the traditional alternate clipboard
|
||||||
if state.keyboard_modifiers.command() {
|
let clip_key = match key.as_ref() {
|
||||||
match key.to_latin(*physical_key) {
|
keyboard::Key::Named(keyboard::key::Named::Insert) if modifiers.shift() => {
|
||||||
|
Some('v')
|
||||||
|
}
|
||||||
|
keyboard::Key::Named(keyboard::key::Named::Insert) if modifiers.command() => {
|
||||||
|
Some('c')
|
||||||
|
}
|
||||||
|
keyboard::Key::Named(keyboard::key::Named::Delete) if modifiers.shift() => {
|
||||||
|
Some('x')
|
||||||
|
}
|
||||||
|
_ if modifiers.command() => key.to_latin(*physical_key),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
{
|
||||||
|
match clip_key {
|
||||||
Some('c') => {
|
Some('c') => {
|
||||||
if !is_secure {
|
if !is_secure {
|
||||||
if let Some((start, end)) = state.cursor.selection(value) {
|
if let Some((start, end)) = state.cursor.selection(value) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue