pub struct Focus {
pub model: String,
pub row: Option<String>,
pub caret: usize,
pub anchor: usize,
pub preedit: Option<(usize, usize)>,
}Expand description
Which input has keyboard focus, and where its caret and selection are.
The selection is the range between anchor (where it started) and caret
(where it has been dragged/extended to); anchor == caret means no selection,
just a caret. Either may be the smaller, dragging leftwards puts the caret
before the anchor, so consumers normalize with Focus::range.
Fields§
§model: String§row: Option<String>The r-key of the r-for row holding this input, when it is in one.
model is the r-model expression as written, so every row of a list
shares it and cannot identify which row the caret is in. The row’s key
is the other half. It also makes the caret follow its row when the list
reorders: the identity is the row, not the position, so nothing has to
be remapped afterwards.
caret: usize§anchor: usize§preedit: Option<(usize, usize)>The byte range of an in-progress IME composition, if one is running. The composed text is already in the bound value; this only marks which part of it is provisional, so the painter can underline it.
Implementations§
Source§impl Focus
impl Focus
Sourcepub fn at(model: impl Into<String>, caret: usize) -> Self
pub fn at(model: impl Into<String>, caret: usize) -> Self
A plain caret with nothing selected, in an input that is not in a list.
Sourcepub fn at_row(
model: impl Into<String>,
row: Option<String>,
caret: usize,
) -> Self
pub fn at_row( model: impl Into<String>, row: Option<String>, caret: usize, ) -> Self
The same, in a known r-for row.
Sourcepub fn is(&self, model: &str, row: Option<&str>) -> bool
pub fn is(&self, model: &str, row: Option<&str>) -> bool
Whether this focus is the input bound to model in row row. Both
halves matter: a list’s rows all share one model.
pub fn is_collapsed(&self) -> bool
Trait Implementations§
impl StructuralPartialEq for Focus
Auto Trait Implementations§
impl Freeze for Focus
impl RefUnwindSafe for Focus
impl Send for Focus
impl Sync for Focus
impl Unpin for Focus
impl UnsafeUnpin for Focus
impl UnwindSafe for Focus
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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 more