Skip to main content

ElementInputHandler

Struct ElementInputHandler 

Source
pub struct ElementInputHandler<V> { /* private fields */ }
Expand description

重导出输入事件相关类型 crate::PlatformInputHandler 的标准实现。在元素绘制时调用 Window::handle_input 并传入实例。

Implementations§

Source§

impl<V: 'static> ElementInputHandler<V>

Source

pub fn new(element_bounds: Bounds<Pixels>, view: Entity<V>) -> Self

用于 Element::paint 中,传入元素边界、Window 和 App 上下文。

Trait Implementations§

Source§

impl<V: EntityInputHandler> InputHandler for ElementInputHandler<V>

Source§

fn selected_text_range( &mut self, ignore_disabled_input: bool, window: &mut Window, cx: &mut App, ) -> Option<UTF16Selection>

获取用户当前选中文本的范围(如果有)。 对应 selectedRange() Read more
Source§

fn marked_text_range( &mut self, window: &mut Window, cx: &mut App, ) -> Option<Range<usize>>

获取当前标记(未确认)文本的范围(如果有)。 对应 markedRange() Read more
Source§

fn text_for_range( &mut self, range_utf16: Range<usize>, adjusted_range: &mut Option<Range<usize>>, window: &mut Window, cx: &mut App, ) -> Option<String>

获取给定文档范围内的文本(以 UTF-16 字符为单位)。 对应 attributedSubstring(forProposedRange: actualRange:) Read more
Source§

fn replace_text_in_range( &mut self, replacement_range: Option<Range<usize>>, text: &str, window: &mut Window, cx: &mut App, )

用给定文本替换文档中指定范围的文本。 对应 insertText(_:replacementRange:) Read more
Source§

fn replace_and_mark_text_in_range( &mut self, range_utf16: Option<Range<usize>>, new_text: &str, new_selected_range: Option<Range<usize>>, window: &mut Window, cx: &mut App, )

用给定文本替换文档中指定范围的文本, 并将给定文本标记为 IME「组合」状态的一部分。 对应 setMarkedText(_:selectedRange:replacementRange:) Read more
Source§

fn unmark_text(&mut self, window: &mut Window, cx: &mut App)

移除文档中的 IME「组合」状态。 对应 unmarkText()
Source§

fn bounds_for_range( &mut self, range_utf16: Range<usize>, window: &mut Window, cx: &mut App, ) -> Option<Bounds<Pixels>>

获取给定文档范围在屏幕坐标中的边界区域。 对应 firstRect(forCharacterRange:actualRange:) Read more
Source§

fn character_index_for_point( &mut self, point: Point<Pixels>, window: &mut Window, cx: &mut App, ) -> Option<usize>

获取给定点在 UTF16 字符中的字符偏移量。 Read more
Source§

fn set_selected_text_range( &mut self, range_utf16: Range<usize>, window: &mut Window, cx: &mut App, )

设置输入中的选中文本范围。
Source§

fn element_bounds( &mut self, _window: &mut Window, _cx: &mut App, ) -> Option<Bounds<Pixels>>

获取元素在屏幕坐标中的边界区域。
Source§

fn text_length_utf16( &mut self, window: &mut Window, cx: &mut App, ) -> Option<usize>

获取文本的长度(以 UTF-16 字符为单位)。
Source§

fn accepts_text_input(&mut self, window: &mut Window, cx: &mut App) -> bool

返回此处理器是否接受要插入的文本输入。
Source§

fn prefers_ime_for_printable_keys( &mut self, window: &mut Window, cx: &mut App, ) -> bool

返回在非 ASCII 输入源(如日语、韩语、中文 IME)激活时, 可打印按键是否应在按键绑定匹配之前先路由到 IME。 这防止了 jj 等多击按键绑定拦截 IME 应该组合的按键。 Read more
Source§

fn apple_press_and_hold_enabled(&mut self) -> bool

允许输入上下文选择接收原始按键重复,而非将其发送到平台。 TODO: 理想情况下应能通过 NSUserDefaults 设置 ApplePressAndHoldEnabled (iTerm 就是这样做的),但目前似乎不生效。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more