pub struct SelectableText { /* private fields */ }Expand description
Typography-aware Material 3 text supporting pointer drag selection,
Ctrl/Cmd+C clipboard copy (through MaterialRoot), and Material
PrimaryContainer selection highlights.
Implementations§
Source§impl SelectableText
impl SelectableText
Sourcepub fn new(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn new( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text with the default TypeRole::BodyLarge role and wrapping enabled.
Sourcepub fn display_large(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn display_large( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::DisplayLarge.
Sourcepub fn display_medium(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn display_medium( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::DisplayMedium.
Sourcepub fn display_small(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn display_small( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::DisplaySmall.
Sourcepub fn headline_large(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn headline_large( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::HeadlineLarge.
Sourcepub fn headline_medium(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn headline_medium( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::HeadlineMedium.
Sourcepub fn headline_small(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn headline_small( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::HeadlineSmall.
Sourcepub fn title_large(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn title_large( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::TitleLarge.
Sourcepub fn title_medium(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn title_medium( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::TitleMedium.
Sourcepub fn title_small(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn title_small( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::TitleSmall.
Sourcepub fn body_large(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn body_large( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::BodyLarge.
Sourcepub fn body_medium(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn body_medium( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::BodyMedium.
Sourcepub fn body_small(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn body_small( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::BodySmall.
Sourcepub fn label_large(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn label_large( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::LabelLarge.
Sourcepub fn label_medium(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn label_medium( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::LabelMedium.
Sourcepub fn label_small(
id: impl Into<ElementId>,
value: impl Into<SharedString>,
) -> SelectableText
pub fn label_small( id: impl Into<ElementId>, value: impl Into<SharedString>, ) -> SelectableText
Creates selectable text styled with TypeRole::LabelSmall.
Sourcepub fn role(self, role: TypeRole) -> SelectableText
pub fn role(self, role: TypeRole) -> SelectableText
Sets the Material typography scale role. Defaults to TypeRole::BodyLarge.
Sourcepub fn emphasized(self, emphasized: bool) -> SelectableText
pub fn emphasized(self, emphasized: bool) -> SelectableText
Selects emphasized typography weight when true, or baseline weight when false.
Sourcepub fn font_scale(self, scale: f32) -> SelectableText
pub fn font_scale(self, scale: f32) -> SelectableText
Applies an additional font-size multiplier on top of the active theme’s typography scale. Non-finite or non-positive scales are ignored.
Sourcepub fn color(self, role: ColorRole) -> SelectableText
pub fn color(self, role: ColorRole) -> SelectableText
Resolves the text color from the active theme’s semantic color role.
Sourcepub fn color_override(self, color: impl Into<Hsla>) -> SelectableText
pub fn color_override(self, color: impl Into<Hsla>) -> SelectableText
Sets a literal text color. A later call to Self::color restores theme-role lookup.
Sourcepub fn muted(self) -> SelectableText
pub fn muted(self) -> SelectableText
Sets the text color to ColorRole::OnSurfaceVariant.
Sourcepub fn selection_color(self, color: impl Into<Hsla>) -> SelectableText
pub fn selection_color(self, color: impl Into<Hsla>) -> SelectableText
Overrides the selection highlight background. Defaults to Material
PrimaryContainer with translucent wash for readability.
Sourcepub fn align(self, align: TextAlign) -> SelectableText
pub fn align(self, align: TextAlign) -> SelectableText
Sets explicit horizontal text alignment. Defaults to the theme’s logical start edge.
Sourcepub fn wrap(self, wrap: bool) -> SelectableText
pub fn wrap(self, wrap: bool) -> SelectableText
Sets whether text wraps at the available width (defaults to true).
Sourcepub fn highlights(
self,
highlights: impl IntoIterator<Item = (Range<usize>, HighlightStyle)>,
) -> SelectableText
pub fn highlights( self, highlights: impl IntoIterator<Item = (Range<usize>, HighlightStyle)>, ) -> SelectableText
Applies ordered, non-overlapping UTF-8 byte-range highlights (such as search matches).
Sourcepub fn group(self, group: &SelectableTextGroup) -> SelectableText
pub fn group(self, group: &SelectableTextGroup) -> SelectableText
Joins a shared SelectableTextGroup so drag selection can span multiple elements.
Sourcepub fn document_order(self, order: u64) -> SelectableText
pub fn document_order(self, order: u64) -> SelectableText
Sets the reading order of this run within its SelectableTextGroup.
Sourcepub fn reveal_range(self, range: Range<usize>) -> SelectableText
pub fn reveal_range(self, range: Range<usize>) -> SelectableText
Requests that the line containing the start of range (UTF-8 byte offset) scroll into view.
Sourcepub fn on_reveal(
self,
handler: impl Fn(Bounds<Pixels>, &mut Window, &mut App) + 'static,
) -> SelectableText
pub fn on_reveal( self, handler: impl Fn(Bounds<Pixels>, &mut Window, &mut App) + 'static, ) -> SelectableText
Receives the bounds of a revealed line for custom scroll containers.
Sourcepub fn accessible_label(self, label: impl Into<SharedString>) -> SelectableText
pub fn accessible_label(self, label: impl Into<SharedString>) -> SelectableText
Overrides the accessible label (defaults to the text value itself).
Trait Implementations§
Source§impl IntoElement for SelectableText
impl IntoElement for SelectableText
Source§type Element = ViewElement<SelectableText>
type Element = ViewElement<SelectableText>
Source§fn into_element(self) -> <SelectableText as IntoElement>::Element
fn into_element(self) -> <SelectableText as IntoElement>::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for SelectableText
impl RenderOnce for SelectableText
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for SelectableText
impl !Send for SelectableText
impl !Sync for SelectableText
impl !UnwindSafe for SelectableText
impl Forget for SelectableText
impl Freeze for SelectableTextwhere
NonZero<u32>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
*const str is !null: Freeze,
PhantomData<&'static str>: Freeze,
*const ArcInner<ElementId> is !null: Freeze,
PhantomData<ArcInner<ElementId>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(Range<usize>, HighlightStyle)>: Freeze,
*const dyn Fn(Bounds<Pixels>, &mut Window, &mut App) is !null: Freeze,
PhantomData<dyn Fn(Bounds<Pixels>, &mut Window, &mut App)>: Freeze,
impl Move for SelectableText
impl Unpin for SelectableText
impl UnsafeUnpin for SelectableTextwhere
NonZeroU32Inner: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
*const ArcInner<ElementId> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementId>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(Range<usize>, HighlightStyle)>: UnsafeUnpin,
*const dyn Fn(Bounds<Pixels>, &mut Window, &mut App) is !null: UnsafeUnpin,
PhantomData<dyn Fn(Bounds<Pixels>, &mut Window, &mut App)>: UnsafeUnpin,
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(
self,
text: impl Into<SharedString>,
) -> ObservedText<Self::Element>
fn test_alt_text( self, text: impl Into<SharedString>, ) -> ObservedText<Self::Element>
Self::test_text for an image’s alternative text, which
stands in for what the element draws.