pub struct TextEditor { /* private fields */ }Expand description
A native plain-text editor (NSTextView in a scroll view) showing a
TextModel: input methods, spell checking, find, undo, text services
and VoiceOver come from AppKit.
Implementations§
Source§impl TextEditor
impl TextEditor
Records edits in the window’s undo history, with its text fields and
app-level changes (undoable), instead of the
editor’s own. Then ⌘Z anywhere in the window undoes the latest
change, wherever it was made.
Sourcepub fn bind(self, text: &Signal<String>) -> Self
pub fn bind(self, text: &Signal<String>) -> Self
Binds the text two ways to text: edits set it (not while an input
method is composing); setting it replaces the editor’s text (clearing
undo, like TextModel::set_text) unless it already matches.
Sourcepub fn on_change(self, f: impl Fn(String) + 'static) -> Self
pub fn on_change(self, f: impl Fn(String) + 'static) -> Self
The text changed (typing, paste, undo, a committed composition).
Sourcepub fn on_selection(self, f: impl Fn(Range<usize>) + 'static) -> Self
pub fn on_selection(self, f: impl Fn(Range<usize>) + 'static) -> Self
The selection or caret moved (UTF-8 byte range).
Sourcepub fn on_composition(self, f: impl Fn(Option<String>) + 'static) -> Self
pub fn on_composition(self, f: impl Fn(Option<String>) + 'static) -> Self
An input method is composing (Some(marked text)) or stopped (None).
Sourcepub fn highlight(
self,
f: impl Fn(&str) -> Vec<(Range<usize>, TextStyle)> + 'static,
) -> Self
pub fn highlight( self, f: impl Fn(&str) -> Vec<(Range<usize>, TextStyle)> + 'static, ) -> Self
Styles the text: f gets the text and returns runs (UTF-8 byte
ranges) with their TextStyles. It runs after every edit, before
it’s drawn, and again when signals it reads change (a search term to
mark, say). See TextModel::set_highlighter.
Sourcepub fn syntax(self, syntax: Syntax) -> Self
pub fn syntax(self, syntax: Syntax) -> Self
Syntax highlighting with syntax (e.g. Syntax::sql),
for code: see code.
Sourcepub fn rich(self) -> Self
pub fn rich(self) -> Self
Rich text: the user styles it (fonts, bold, colours, alignment,
lists, pictures) with ⌘B and friends, the font panel and
format_menu; see TextModel::set_rich.
Read and load it as RTF or HTML on the model, or bind it with
bind_rtf.
Sourcepub fn format_bar(self) -> Self
pub fn format_bar(self) -> Self
Rich text with TextEdit’s format bar above it (font, size, colours, bold, italic, alignment, spacing, lists).
Sourcepub fn bind_rtf(self, rtf: &Signal<Vec<u8>>) -> Self
pub fn bind_rtf(self, rtf: &Signal<Vec<u8>>) -> Self
Rich text bound two ways to rtf, its RTF (what a rich document
saves): edits, styling ones too, set it; setting it loads it
(clearing undo) unless it’s what the editor shows.
Sourcepub fn code(self) -> Self
pub fn code(self) -> Self
An editor for code: quotes and dashes stay as typed (no smart
quotes), and no text replacement, autocorrection or spell checking
(TextModel::set_code_input). syntax implies it.
Trait Implementations§
Source§impl View for TextEditor
impl View for TextEditor
Auto Trait Implementations§
impl !RefUnwindSafe for TextEditor
impl !Send for TextEditor
impl !Sync for TextEditor
impl !UnwindSafe for TextEditor
impl Forget for TextEditor
impl Freeze for TextEditor
impl Move for TextEditor
impl Unpin for TextEditor
impl UnsafeUnpin for TextEditor
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn on_command(
self,
command: Command,
action: impl Fn() + 'static,
) -> Modified<Self>
fn on_command( self, command: Command, action: impl Fn() + 'static, ) -> Modified<Self>
command while the focus is in this view (see
Command).Source§fn on_command_when(
self,
command: Command,
enabled: impl Fn() -> bool + 'static,
action: impl Fn() + 'static,
) -> Modified<Self>
fn on_command_when( self, command: Command, enabled: impl Fn() -> bool + 'static, action: impl Fn() + 'static, ) -> Modified<Self>
command, enabled only while enabled returns true.Source§fn focused_value<T: Clone + 'static>(
self,
name: &'static str,
value: T,
) -> Modified<Self>
fn focused_value<T: Clone + 'static>( self, name: &'static str, value: T, ) -> Modified<Self>
Source§fn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self>
fn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self>
horizontal points left and right and vertical above and
below: a row’s .padding_xy(10.0, 7.0), as SwiftUI’s
.padding(.horizontal, 10) and .padding(.vertical, 7).Source§fn min_width(self, points: f64) -> Modified<Self>
fn min_width(self, points: f64) -> Modified<Self>
points wide (SwiftUI’s frame(minWidth:)).Source§fn min_height(self, points: f64) -> Modified<Self>
fn min_height(self, points: f64) -> Modified<Self>
points tall (SwiftUI’s frame(minHeight:)).Source§fn fill_width(self) -> Modified<Self>
fn fill_width(self) -> Modified<Self>
Source§fn fill_height(self) -> Modified<Self>
fn fill_height(self) -> Modified<Self>
Source§fn popover<P: View>(
self,
shown: &Signal<bool>,
content: impl Fn() -> P + 'static,
) -> Modified<Self>
fn popover<P: View>( self, shown: &Signal<bool>, content: impl Fn() -> P + 'static, ) -> Modified<Self>
Source§fn accessibility_label(self, label: &str) -> Modified<Self>
fn accessibility_label(self, label: &str) -> Modified<Self>
text("Name:"), an icon button).Source§fn background(self, color: impl IntoValue<Color>) -> Modified<Self>
fn background(self, color: impl IntoValue<Color>) -> Modified<Self>
corner_radius and shadow, a
card. Color::QuaternaryFill is the system’s grouped-card colour.
A closure computes it from signals (a selected row, a status); it
changes smoothly inside animated.Source§fn corner_radius(self, points: f64) -> Modified<Self>
fn corner_radius(self, points: f64) -> Modified<Self>
Source§fn border(self, color: Color, width: f64) -> Modified<Self>
fn border(self, color: Color, width: f64) -> Modified<Self>
width points wide around the view (inside its padding).Source§fn shadow(self, shadow: Shadow) -> Modified<Self>
fn shadow(self, shadow: Shadow) -> Modified<Self>
Source§fn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self>
fn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self>
opacity (0 transparent, 1 opaque), all of it, or a
closure computing it from signals; it fades inside
animated.Source§fn font(self, font: Font) -> Modified<Self>
fn font(self, font: Font) -> Modified<Self>
Source§fn color(self, color: impl IntoValue<Color>) -> Modified<Self>
fn color(self, color: impl IntoValue<Color>) -> Modified<Self>
Source§fn accessibility_value(self, value: impl IntoValue<String>) -> Modified<Self>
fn accessibility_value(self, value: impl IntoValue<String>) -> Modified<Self>
Source§fn material(self, material: Material) -> Modified<Self>
fn material(self, material: Material) -> Modified<Self>
corner_radius rounds it.Source§fn glass(self, glass: Glass) -> Modified<Self>
fn glass(self, glass: Glass) -> Modified<Self>
corner_radius
rounds it.Source§fn background_when(self, color: impl Fn() -> Color + 'static) -> Modified<Self>
fn background_when(self, color: impl Fn() -> Color + 'static) -> Modified<Self>
background takes a closure: .background(move || ..)
background
takes a closure).Source§fn opacity_when(self, opacity: impl Fn() -> f64 + 'static) -> Modified<Self>
fn opacity_when(self, opacity: impl Fn() -> f64 + 'static) -> Modified<Self>
opacity takes a closure: .opacity(move || ..)
opacity takes a
closure).Source§fn transition(self, transition: Transition) -> Modified<Self>
fn transition(self, transition: Transition) -> Modified<Self>
Source§fn matched_geometry(self, id: &str) -> Modified<Self>
fn matched_geometry(self, id: &str) -> Modified<Self>
matchedGeometryEffect): when, in one
animated change, a view with this id goes
and another with it comes (a thumbnail replaced by its detail, a
selection marker moving), the new one starts where and as large as
the old one was, and moves to its place.Source§fn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self>
fn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self>
action with true when the pointer moves over the view and
false when it leaves (while the app is active).Source§fn hover_highlight(self, color: Color) -> Modified<Self>
fn hover_highlight(self, color: Color) -> Modified<Self>
color while the pointer is over the view, fading
in and out: for rows and cards that can be clicked.Source§fn tooltip(self, text: &str) -> Modified<Self>
fn tooltip(self, text: &str) -> Modified<Self>
text appears in a small box when the pointer rests on
the view (SwiftUI’s help). VoiceOver reads it as the view’s help.when() is true, following the signals it
reads: its native views stay built (no rebuild, the state inside
kept) but aren’t shown, and it takes no room in its stack, as if it
weren’t there. For a panel shown in one mode only, rather than a
dynamic that rebuilds it each time. VoiceOver and Tab skip it.