diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -5,9 +5,12 @@ #[cfg(feature = "markdown")] pub mod markdown; +pub mod operation; +pub mod selectable; pub mod selection; pub mod text; +use core::Element; use iced_widget::core; use iced_widget::graphics::text::Paragraph; #[cfg(feature = "markdown")] @@ -225,3 +228,45 @@ pub fn span<'a, Link>( ) -> text::Span<'a, Link, core::Font> { text::Span::new(text) } + +/// Creates some [`Selectable`] with the given content. +/// +/// [`Selectable`]: crate::selectable::Selectable +/// +/// # Example +/// ```no_run,ignore +/// use iced::font; +/// use iced_selection::{rich_text, selectable, span}; +/// use iced::{color, column, never, Font}; +/// +/// #[derive(Debug, Clone)] +/// enum Message { +/// LinkClicked(&'static str), +/// // ... +/// } +/// +/// fn view(state: &State) -> Element<'_, Message> { +/// selectable( +/// column![ +/// rich_text([ +/// span("I am red!").color(color!(0xff0000)), +/// span(" "), +/// span("And I am bold!").font(Font { weight: font::Weight::Bold, ..Font::default() }), +/// ]) +/// .on_link_click(never) +/// .size(20), +/// text("Hello, this is iced!"), +/// ] +/// ) +/// .into() +/// } +/// ``` +pub fn selectable<'a, Message, Theme, Renderer>( + content: impl Into<Element<'a, Message, Theme, Renderer>>, +) -> selectable::Selectable<'a, Message, Theme, Renderer> +where + Theme: 'a, + Renderer: core::Renderer, +{ + selectable::Selectable::new(content) +} |
