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
|
||||
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
|
||||
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.
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
@ -197,19 +204,18 @@ impl<'a, Message: Clone + 'static> ListColumn<'a, Message> {
|
|||
dnd_source_builder,
|
||||
dnd_destination_builder,
|
||||
}) => {
|
||||
let mut button: Element<'a, Message> =
|
||||
content_row(content)
|
||||
.apply(button::custom)
|
||||
.padding(item_padding)
|
||||
.width(Length::Fill)
|
||||
.on_press_maybe(on_press)
|
||||
.selected(selected)
|
||||
.class(theme::Button::ListItem(get_radius(
|
||||
radius_s,
|
||||
i == 0,
|
||||
i == last_index,
|
||||
)))
|
||||
.into();
|
||||
let mut button: Element<'a, Message> = content_row(content)
|
||||
.apply(button::custom)
|
||||
.padding(item_padding)
|
||||
.width(Length::Fill)
|
||||
.on_press_maybe(on_press)
|
||||
.selected(selected)
|
||||
.class(theme::Button::ListItem(get_radius(
|
||||
radius_s,
|
||||
i == 0,
|
||||
i == last_index,
|
||||
)))
|
||||
.into();
|
||||
if let Some(builder) = dnd_source_builder {
|
||||
button = builder(button).into();
|
||||
}
|
||||
|
|
@ -219,7 +225,7 @@ impl<'a, Message: Clone + 'static> ListColumn<'a, Message> {
|
|||
}
|
||||
|
||||
col.push(button)
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1821,9 +1821,22 @@ pub fn update<'a, Message: Clone + 'static>(
|
|||
focus.updated_at = Instant::now();
|
||||
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
||||
|
||||
// Check if Ctrl/Command+A/C/V/X was pressed.
|
||||
if state.keyboard_modifiers.command() {
|
||||
match key.to_latin(*physical_key) {
|
||||
// Ctrl/Command+A/C/V/X, plus the traditional alternate clipboard
|
||||
let clip_key = match key.as_ref() {
|
||||
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') => {
|
||||
if !is_secure {
|
||||
if let Some((start, end)) = state.cursor.selection(value) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue