pub struct ElementInputHandler<V> { /* private fields */ }Expand description
重导出输入事件相关类型
crate::PlatformInputHandler 的标准实现。在元素绘制时调用
Window::handle_input 并传入实例。
Implementations§
Source§impl<V: 'static> ElementInputHandler<V>
impl<V: 'static> ElementInputHandler<V>
Trait Implementations§
Source§impl<V: EntityInputHandler> InputHandler for ElementInputHandler<V>
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>
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>>
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>
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,
)
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,
)
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)
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>>
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>
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,
)
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>>
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>
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
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
fn prefers_ime_for_printable_keys( &mut self, window: &mut Window, cx: &mut App, ) -> bool
返回在非 ASCII 输入源(如日语、韩语、中文 IME)激活时,
可打印按键是否应在按键绑定匹配之前先路由到 IME。
这防止了
jj 等多击按键绑定拦截 IME 应该组合的按键。 Read moreSource§fn apple_press_and_hold_enabled(&mut self) -> bool
fn apple_press_and_hold_enabled(&mut self) -> bool
允许输入上下文选择接收原始按键重复,而非将其发送到平台。
TODO: 理想情况下应能通过 NSUserDefaults 设置 ApplePressAndHoldEnabled
(iTerm 就是这样做的),但目前似乎不生效。
Auto Trait Implementations§
impl<V> !RefUnwindSafe for ElementInputHandler<V>
impl<V> !UnwindSafe for ElementInputHandler<V>
impl<V> Forget for ElementInputHandler<V>
impl<V> Freeze for ElementInputHandler<V>
impl<V> Move for ElementInputHandler<V>
impl<V> Send for ElementInputHandler<V>
impl<V> Sync for ElementInputHandler<V>
impl<V> Unpin for ElementInputHandler<V>
impl<V> UnsafeUnpin for ElementInputHandler<V>where
Entity<V>: UnsafeUnpin,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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 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> ⓘ
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