Fix doc warnings during build

Add some docs for the text cursor blinker, which is public now
due to the use in the rendering backends.
This commit is contained in:
Simon Hausmann 2021-01-14 11:16:09 +01:00
parent dc0a59a713
commit c8065060c5

View file

@ -589,6 +589,8 @@ pub struct TextCursorBlinker {
}
impl TextCursorBlinker {
/// Creates a new instance, wrapped in a Pin<Rc<_>> because the boolean property
/// the blinker properties uses the property system that requires pinning.
pub fn new() -> Pin<Rc<Self>> {
Rc::pin(Self {
cursor_visible: Property::new(true),
@ -596,6 +598,8 @@ impl TextCursorBlinker {
})
}
/// Sets a binding on the provided property that will ensure that the property value
/// is true when the cursor should be shown and false if not.
pub fn set_binding(instance: Pin<Rc<TextCursorBlinker>>, prop: &Property<bool>) {
instance.as_ref().cursor_visible.set(true);
// Re-start timer, in case.
@ -605,6 +609,8 @@ impl TextCursorBlinker {
});
}
/// Starts the blinking cursor timer that will toggle the cursor and update all bindings that
/// were installed on properties with set_binding call.
pub fn start(self: &Pin<Rc<Self>>) {
if self.cursor_blink_timer.running() {
self.cursor_blink_timer.restart();
@ -629,6 +635,8 @@ impl TextCursorBlinker {
}
}
/// Stops the blinking cursor timer. This is usually used for example when the window that contains
/// text editable elements looses the focus or is hidden.
pub fn stop(&self) {
self.cursor_blink_timer.stop()
}