feat: add context menu support to selectable Text widget
This commit is contained in:
parent
43a50cb6f5
commit
834cd366ee
2 changed files with 494 additions and 44 deletions
|
|
@ -1370,18 +1370,19 @@ impl iced_widget::text::Catalog for Theme {
|
|||
}
|
||||
|
||||
fn style(&self, class: &Self::Class<'_>) -> iced_widget::text::Style {
|
||||
let selected_fill = self.cosmic().accent.base.into();
|
||||
match class {
|
||||
Text::Accent => iced_widget::text::Style {
|
||||
color: Some(self.cosmic().accent_text_color().into()),
|
||||
..Default::default()
|
||||
selected_fill,
|
||||
},
|
||||
Text::Default => iced_widget::text::Style {
|
||||
color: None,
|
||||
..Default::default()
|
||||
selected_fill,
|
||||
},
|
||||
Text::Color(c) => iced_widget::text::Style {
|
||||
color: Some(*c),
|
||||
..Default::default()
|
||||
selected_fill,
|
||||
},
|
||||
Text::Custom(f) => f(self),
|
||||
}
|
||||
|
|
@ -1527,6 +1528,12 @@ pub enum TextEditor<'a> {
|
|||
Custom(text_editor::StyleFn<'a, Theme>),
|
||||
}
|
||||
|
||||
impl<'a> From<text_editor::StyleFn<'a, Theme>> for TextEditor<'a> {
|
||||
fn from(style: text_editor::StyleFn<'a, Theme>) -> Self {
|
||||
Self::Custom(style)
|
||||
}
|
||||
}
|
||||
|
||||
impl iced_widget::text_editor::Catalog for Theme {
|
||||
type Class<'a> = TextEditor<'a>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue