FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    RichTextBlock

    struct · ferroui-controls · v0.5.0

    struct RichTextBlock
    

    Displays paragraphs, nested spans, hyperlinks and embedded controls. All text indices are UTF-16 code units, matching the shaping and input-method contracts.

    View source

    Members

    context_menu_opening_event

    fn context_menu_opening_event() -> &'static RoutedEvent<ContextMenuEventArgs>
    

    Raised synchronously before this view opens a configured context menu or flyout. Handled cancels the associated request.

    Native overflow views do not raise this event for the modern context-flyout path. Their configured flyout still opens at the requesting overflow, including one inherited from the master.

    Source

    context_menu_opening

    fn context_menu_opening(self: &Self, handler: impl Fn(&Interactive, &ContextMenuEventArgs) -> () + 'static) -> RoutedEventHandlerToken
    

    Source

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<RichTextBlock>
    

    Returns a strong reference to this object.

    Source

    render_text

    fn render_text(self: &Self, context: &mut DrawingContext<'_>)
    

    Paints text content after the background and selection highlights.

    Source

    caret_visible

    fn caret_visible(self: &Self) -> bool
    

    Whether the insertion caret is visible (editable views override this).

    Source

    fn allow_hyperlink_navigation(self: &Self, modifiers: KeyModifiers) -> bool
    

    Whether pointer input activates a hyperlink or edits its text.

    Source

    on_selection_changing

    fn on_selection_changing(self: &Self, args: &RichTextSelectionChangedEventArgs) -> bool
    

    Runs synchronously while the proposed selection is visible to readers. Returning false cancels it unless a handler selected a different range.

    Source

    request_selection_change

    fn request_selection_change(self: &Self, start: usize, end: usize) -> bool
    

    Lets an editable view arbitrate a normalized selection through its editor.

    Source

    rebase_selection_on_document_change

    fn rebase_selection_on_document_change(self: &Self) -> bool
    

    Editors publish their final transaction selection after document changes.

    Source

    text_insets

    fn text_insets(self: &Self) -> Thickness
    

    Space outside the document's formatted text, including editor adornments.

    Source

    text_layout_constraint

    fn text_layout_constraint(self: &Self, available_size: Size) -> Size
    

    The formatter constraint, independent of a scrollable view's viewport.

    Source

    default_incremental_tab

    fn default_incremental_tab(self: &Self, font_size: f64) -> f64
    

    Implicit tab interval for a paragraph without an assigned override.

    Source

    text_origin

    fn text_origin(self: &Self) -> Point
    

    Shared origin for text, inline controls, caret, selection and hit testing.

    Source

    selection_is_visible

    fn selection_is_visible(self: &Self) -> bool
    

    Whether the selection is currently drawn in this view (its highlight, and the selection foreground of the selected text).

    Source

    selection_render_brush

    fn selection_render_brush(self: &Self) -> Option<Rc<dyn IBrush>>
    

    The selection background after the host's focus policy is applied.

    Source

    raise_selection_changed_event

    fn raise_selection_changed_event(self: &Self)
    

    Publishes the selection event on the owning control.

    Source

    text_focus_target

    fn text_focus_target(self: &Self) -> Ref<InputElement>
    

    The keyboard focus target for pointer interaction with text.

    Source

    text_background_bounds

    fn text_background_bounds(self: &Self) -> Rect
    

    Bounds painted by the document background; editor headers are outside it.

    Source

    additional_visual_children

    fn additional_visual_children(self: &Self) -> Vec<Ref<Visual>>
    

    Native framework visuals displayed beside the document's inline controls.

    Source

    rich_document_property

    fn rich_document_property() -> &'static DirectProperty<RichTextBlock, RichTextDocument>
    

    The shared document the view shows: a FerroUI addition (WinUI's RichTextBlock has only Blocks), named RichDocument so that it never reads as the text object model RichEditBox.Document is (docs/porting/winui-rich-text.md, D3).

    Source

    selection_start_property

    fn selection_start_property() -> &'static DirectProperty<RichTextBlock, i32>
    

    Source

    selection_end_property

    fn selection_end_property() -> &'static DirectProperty<RichTextBlock, i32>
    

    Source

    selected_text_property

    fn selected_text_property() -> &'static DirectProperty<RichTextBlock, String>
    

    Source

    is_text_selection_enabled_property

    fn is_text_selection_enabled_property() -> &'static StyledProperty<bool>
    

    Source

    selection_highlight_color_property

    fn selection_highlight_color_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Source

    selection_foreground_brush_property

    fn selection_foreground_brush_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Source

    caret_brush_property

    fn caret_brush_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Source

    background_property

    fn background_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Source

    padding_property

    fn padding_property() -> &'static StyledProperty<Thickness>
    

    Source

    font_family_property

    fn font_family_property() -> &'static StyledProperty<FontFamily>
    

    Source

    font_size_property

    fn font_size_property() -> &'static StyledProperty<f64>
    

    Source

    font_style_property

    fn font_style_property() -> &'static StyledProperty<FontStyle>
    

    Source

    font_weight_property

    fn font_weight_property() -> &'static StyledProperty<FontWeight>
    

    Source

    font_stretch_property

    fn font_stretch_property() -> &'static StyledProperty<FontStretch>
    

    Source

    font_features_property

    fn font_features_property() -> &'static StyledProperty<Option<FontFeatureCollection>>
    

    Source

    language_property

    fn language_property() -> &'static StyledProperty<ferroui_base::utilities::Locale>
    

    Source

    foreground_property

    fn foreground_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Source

    letter_spacing_property

    fn letter_spacing_property() -> &'static StyledProperty<f64>
    

    Source

    text_alignment_property

    fn text_alignment_property() -> &'static StyledProperty<TextAlignment>
    

    Source

    line_height_property

    fn line_height_property() -> &'static StyledProperty<f64>
    

    Source

    text_indent_property

    fn text_indent_property() -> &'static StyledProperty<f64>
    

    Source

    line_stacking_strategy_property

    fn line_stacking_strategy_property() -> &'static StyledProperty<LineStackingStrategy>
    

    Source

    text_line_bounds_property

    fn text_line_bounds_property() -> &'static StyledProperty<TextLineBounds>
    

    Source

    text_decorations_property

    fn text_decorations_property() -> &'static StyledProperty<Option<TextDecorationCollection>>
    

    Source

    text_trimming_property

    fn text_trimming_property() -> &'static StyledProperty<Rc<dyn TextTrimming>>
    

    Source

    text_wrapping_property

    fn text_wrapping_property() -> &'static StyledProperty<TextWrapping>
    

    Source

    max_lines_property

    fn max_lines_property() -> &'static StyledProperty<i32>
    

    Source

    overflow_content_target_property

    fn overflow_content_target_property() -> &'static StyledProperty<Option<ElementRef<RichTextBlockOverflow>>>
    

    Source

    has_overflow_content_property

    fn has_overflow_content_property() -> &'static DirectProperty<RichTextBlock, bool>
    

    Source

    baseline_offset_property

    fn baseline_offset_property() -> &'static DirectProperty<RichTextBlock, f64>
    

    Source

    is_text_trimmed_property

    fn is_text_trimmed_property() -> &'static DirectProperty<RichTextBlock, bool>
    

    Source

    selection_changed_event

    fn selection_changed_event() -> &'static RoutedEvent<RoutedEventArgs>
    

    Source

    is_text_trimmed_changed_event

    fn is_text_trimmed_changed_event() -> &'static RoutedEvent<RoutedEventArgs>
    

    Source

    construct

    fn construct() -> Self
    

    Source

    new

    fn new() -> Ref<Self>
    

    Source

    rich_document

    fn rich_document(self: &Self) -> RichTextDocument
    

    The shared document of the view (the property RichDocument, D3).

    Source

    set_rich_document

    fn set_rich_document(self: &Self, value: RichTextDocument)
    

    Sets the shared document of the view (the property RichDocument, D3).

    Source

    try_set_rich_document

    fn try_set_rich_document(self: &Self, value: RichTextDocument) -> bool
    

    Attaches a shared document whose blocks no other view owns; see try_set_document.

    Source

    document

    fn document(self: &Self) -> RichTextDocument
    

    Source

    set_document

    fn set_document(self: &Self, value: RichTextDocument)
    

    Source

    try_set_document

    fn try_set_document(self: &Self, value: RichTextDocument) -> bool
    

    Attaches a document whose block elements are not owned by another view. Use an overflow target to share a view's document, or restore a snapshot into another document to make an independent view.

    Source

    blocks

    fn blocks(self: &Self) -> BlockCollection
    

    Source

    text_highlighters

    fn text_highlighters(self: &Self) -> TextHighlighterCollection
    

    Source

    add_child

    fn add_child(self: &Self, block: impl IntoRef<Block>)
    

    Source

    text

    fn text(self: &Self) -> String
    

    Source

    selection_start

    fn selection_start(self: &Self) -> usize
    

    Source

    selection_end

    fn selection_end(self: &Self) -> usize
    

    Source

    caret_index

    fn caret_index(self: &Self) -> usize
    

    Source

    set_selection_start

    fn set_selection_start(self: &Self, value: usize)
    

    Source

    set_selection_end

    fn set_selection_end(self: &Self, value: usize)
    

    Source

    select

    fn select(self: &Self, start: usize, end: usize)
    

    Source

    selection_changed

    fn selection_changed(self: &Self, handler: impl Fn(&RichTextSelectionChangedEventArgs) -> () + 'static) -> Subscription
    

    Adds a handler of the changes of the selection.

    Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the block.

    Source

    selected_text

    fn selected_text(self: &Self) -> String
    

    Source

    select_all

    fn select_all(self: &Self)
    

    Source

    clear_selection

    fn clear_selection(self: &Self)
    

    Source

    can_copy

    fn can_copy(self: &Self) -> bool
    

    Source

    fn hyperlink_at(self: &Self, point: Point) -> Option<Ref<Hyperlink>>
    

    Finds a hyperlink inside rendered content, excluding blank padding.

    Source

    copy

    fn copy(self: &Self)
    

    Source

    export_rtf

    fn export_rtf(self: &Self) -> Result<String, crate::rich_text::RtfError>
    

    Exports using the same resolved tab intervals as this view and its overflow chain. RTF has one document-wide default interval, so paragraphs resolving to different intervals return an unsupported-feature error.

    Source

    hit_test_text_position

    fn hit_test_text_position(self: &Self, point: Point) -> usize
    

    Source

    get_rect_from_character_index

    fn get_rect_from_character_index(self: &Self, index: usize) -> Rect
    

    Source

    get_rect_from_text_position

    fn get_rect_from_text_position(self: &Self, position: TextPosition) -> Rect
    

    Gets a caret rectangle at the leading or trailing character edge of the same UTF-16 insertion position. Affinity matters at a bidi run boundary.

    Source

    text_view_for_position

    fn text_view_for_position(self: &Self, index: usize) -> Option<Ref<RichTextBlock>>
    

    Finds the view containing a document insertion position. A terminal insertion point belongs to the final column; an off-page position has no view until enough overflow columns are linked and laid out.

    Source

    cursor_rectangle

    fn cursor_rectangle(self: &Self) -> Rect
    

    Source

    selection_rects

    fn selection_rects(self: &Self) -> Vec<Rect>
    

    Source

    get_rects_for_range

    fn get_rects_for_range(self: &Self, range: Range<usize>) -> Vec<Rect>
    

    Gets the visible bounds of a UTF-16 range without changing selection. Invalid or empty ranges have no rectangles. Overflow views return only the rectangles within their own formatted page.

    Source

    line_metrics

    fn line_metrics(self: &Self) -> Vec<RichTextLineMetrics>
    

    Source

    visible_text_ranges

    fn visible_text_ranges(self: &Self) -> Vec<Range<usize>>
    

    Source ranges retained in this formatted page, excluding collapsed text represented by an ellipsis. Ancestor viewports may clip these further.

    Source

    is_text_trimmed

    fn is_text_trimmed(self: &Self) -> bool
    

    Source

    baseline_offset

    fn baseline_offset(self: &Self) -> f64
    

    Source

    has_overflow_content

    fn has_overflow_content(self: &Self) -> bool
    

    Source

    content_start

    fn content_start(self: &Self) -> usize
    

    Source

    content_end

    fn content_end(self: &Self) -> usize
    

    Source

    is_text_selection_enabled

    fn is_text_selection_enabled(self: &Self) -> bool
    

    Source

    set_is_text_selection_enabled

    fn set_is_text_selection_enabled(self: &Self, value: bool)
    

    Source

    selection_highlight_color

    fn selection_highlight_color(self: &Self) -> Option<Rc<dyn IBrush>>
    

    Source

    set_selection_highlight_color

    fn set_selection_highlight_color(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    selection_foreground_brush

    fn selection_foreground_brush(self: &Self) -> Option<Rc<dyn IBrush>>
    

    Source

    set_selection_foreground_brush

    fn set_selection_foreground_brush(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    caret_brush

    fn caret_brush(self: &Self) -> Option<Rc<dyn IBrush>>
    

    Source

    set_caret_brush

    fn set_caret_brush(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    background

    fn background(self: &Self) -> Option<Rc<dyn IBrush>>
    

    Source

    set_background

    fn set_background(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    padding

    fn padding(self: &Self) -> Thickness
    

    Source

    set_padding

    fn set_padding(self: &Self, value: Thickness)
    

    Source

    font_family

    fn font_family(self: &Self) -> FontFamily
    

    Source

    set_font_family

    fn set_font_family(self: &Self, value: FontFamily)
    

    Source

    font_size

    fn font_size(self: &Self) -> f64
    

    Source

    set_font_size

    fn set_font_size(self: &Self, value: f64)
    

    Source

    font_style

    fn font_style(self: &Self) -> FontStyle
    

    Source

    set_font_style

    fn set_font_style(self: &Self, value: FontStyle)
    

    Source

    font_weight

    fn font_weight(self: &Self) -> FontWeight
    

    Source

    set_font_weight

    fn set_font_weight(self: &Self, value: FontWeight)
    

    Source

    font_stretch

    fn font_stretch(self: &Self) -> FontStretch
    

    Source

    set_font_stretch

    fn set_font_stretch(self: &Self, value: FontStretch)
    

    Source

    font_features

    fn font_features(self: &Self) -> Option<FontFeatureCollection>
    

    Source

    language

    fn language(self: &Self) -> ferroui_base::utilities::Locale
    

    Source

    set_language

    fn set_language(self: &Self, value: ferroui_base::utilities::Locale)
    

    Source

    set_font_features

    fn set_font_features(self: &Self, value: Option<FontFeatureCollection>)
    

    Source

    foreground

    fn foreground(self: &Self) -> Option<Rc<dyn IBrush>>
    

    Source

    set_foreground

    fn set_foreground(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    letter_spacing

    fn letter_spacing(self: &Self) -> f64
    

    Source

    set_letter_spacing

    fn set_letter_spacing(self: &Self, value: f64)
    

    Source

    text_alignment

    fn text_alignment(self: &Self) -> TextAlignment
    

    Source

    set_text_alignment

    fn set_text_alignment(self: &Self, value: TextAlignment)
    

    Source

    horizontal_text_alignment

    fn horizontal_text_alignment(self: &Self) -> TextAlignment
    

    Source

    set_horizontal_text_alignment

    fn set_horizontal_text_alignment(self: &Self, value: TextAlignment)
    

    Source

    text_indent

    fn text_indent(self: &Self) -> f64
    

    Source

    set_text_indent

    fn set_text_indent(self: &Self, value: f64)
    

    Source

    line_stacking_strategy

    fn line_stacking_strategy(self: &Self) -> LineStackingStrategy
    

    Source

    set_line_stacking_strategy

    fn set_line_stacking_strategy(self: &Self, value: LineStackingStrategy)
    

    Source

    text_line_bounds

    fn text_line_bounds(self: &Self) -> TextLineBounds
    

    The shared formatter's bounds policy for every line in this document. The value is inherited from the framework's TextBlock attached property.

    Source

    set_text_line_bounds

    fn set_text_line_bounds(self: &Self, value: TextLineBounds)
    

    Source

    text_decorations

    fn text_decorations(self: &Self) -> Option<TextDecorationCollection>
    

    Source

    set_text_decorations

    fn set_text_decorations(self: &Self, value: Option<TextDecorationCollection>)
    

    Source

    text_trimming

    fn text_trimming(self: &Self) -> Rc<dyn TextTrimming>
    

    Source

    set_text_trimming

    fn set_text_trimming(self: &Self, value: Rc<dyn TextTrimming>)
    

    Source

    line_height

    fn line_height(self: &Self) -> f64
    

    Source

    set_line_height

    fn set_line_height(self: &Self, value: f64)
    

    Source

    text_wrapping

    fn text_wrapping(self: &Self) -> TextWrapping
    

    Source

    set_text_wrapping

    fn set_text_wrapping(self: &Self, value: TextWrapping)
    

    Source

    max_lines

    fn max_lines(self: &Self) -> usize
    

    Source

    set_max_lines

    fn set_max_lines(self: &Self, value: usize)
    

    Source

    overflow_content_target

    fn overflow_content_target(self: &Self) -> Option<Ref<RichTextBlockOverflow>>
    

    Source

    try_set_overflow_content_target

    fn try_set_overflow_content_target(self: &Self, target: Option<Ref<RichTextBlockOverflow>>) -> bool
    

    Links an overflow view. Cycles and a target already owned by another view are rejected without changing either chain.

    Source

    set_overflow_content_target

    fn set_overflow_content_target(self: &Self, target: Option<Ref<RichTextBlockOverflow>>)
    

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.