Struct i_slint_core::window::Window
source · [−]pub struct Window { /* private fields */ }
Expand description
Structure that represent a Window in the runtime
Implementations
sourceimpl Window
impl Window
sourcepub fn new(
platform_window_fn: impl FnOnce(&Weak<Window>) -> Rc<dyn PlatformWindow>
) -> Rc<Self>
pub fn new(
platform_window_fn: impl FnOnce(&Weak<Window>) -> Rc<dyn PlatformWindow>
) -> Rc<Self>
Create a new instance of the window, given the platform_window factory fn
sourcepub fn set_component(&self, component: &ComponentRc)
pub fn set_component(&self, component: &ComponentRc)
Associates this window with the specified component. Further event handling and rendering, etc. will be done with that component.
sourcepub fn component(&self) -> ComponentRc
pub fn component(&self) -> ComponentRc
return the component. Panics if it wasn’t set.
sourcepub fn try_component(&self) -> Option<ComponentRc>
pub fn try_component(&self) -> Option<ComponentRc>
returns the component or None if it isn’t set.
sourcepub fn process_mouse_input(self: Rc<Self>, event: MouseEvent)
pub fn process_mouse_input(self: Rc<Self>, event: MouseEvent)
Receive a mouse event and pass it to the items of the component to change their state.
Arguments:
pos
: The position of the mouse event in window physical coordinates.what
: The type of mouse event.component
: The Slint compiled component that provides the tree of items.
sourcepub fn process_key_input(self: Rc<Self>, event: &KeyEvent)
pub fn process_key_input(self: Rc<Self>, event: &KeyEvent)
Receive a key event and pass it to the items of the component to change their state.
Arguments:
event
: The key event received by the windowing system.component
: The Slint compiled component that provides the tree of items.
sourcepub fn set_cursor_blink_binding(&self, prop: &Property<bool>)
pub fn set_cursor_blink_binding(&self, prop: &Property<bool>)
Installs a binding on the specified property that’s toggled whenever the text cursor is supposed to be visible or not.
sourcepub fn set_focus_item(self: Rc<Self>, focus_item: &ItemRc)
pub fn set_focus_item(self: Rc<Self>, focus_item: &ItemRc)
Sets the focus to the item pointed to by item_ptr. This will remove the focus from any currently focused item.
sourcepub fn set_focus(self: Rc<Self>, have_focus: bool)
pub fn set_focus(self: Rc<Self>, have_focus: bool)
Sets the focus on the window to true or false, depending on the have_focus argument. This results in WindowFocusReceived and WindowFocusLost events.
sourcepub fn focus_next_item(self: Rc<Self>)
pub fn focus_next_item(self: Rc<Self>)
Move keyboard focus to the next item
sourcepub fn focus_previous_item(self: Rc<Self>)
pub fn focus_previous_item(self: Rc<Self>)
Move keyboard focus to the previous item.
sourcepub fn set_active(&self, active: bool)
pub fn set_active(&self, active: bool)
Marks the window to be the active window. This typically coincides with the keyboard focus. One exception though is when a popup is shown, in which case the window may remain active but temporarily loose focus to the popup.
sourcepub fn active(&self) -> bool
pub fn active(&self) -> bool
Returns true of the window is the active window. That typically implies having the keyboard focus, except when a popup is shown and temporarily takes the focus.
sourcepub fn update_window_properties(&self)
pub fn update_window_properties(&self)
If the component’s root item is a Window element, then this function synchronizes its properties, such as the title for example, with the properties known to the windowing system.
sourcepub fn draw_contents(
self: Rc<Self>,
render_components: impl FnOnce(&[(&ComponentRc, Point)])
)
pub fn draw_contents(
self: Rc<Self>,
render_components: impl FnOnce(&[(&ComponentRc, Point)])
)
Calls the render_components to render the main component and any sub-window components, tracked by a property dependency tracker.
sourcepub fn show(&self)
pub fn show(&self)
Registers the window with the windowing system, in order to render the component’s items and react to input events once the event loop spins.
sourcepub fn set_active_popup(&self, popup: PopupWindow) -> Size
pub fn set_active_popup(&self, popup: PopupWindow) -> Size
Registers the specified window and component to be considered the active popup. Returns the size of the popup.
sourcepub fn show_popup(
&self,
popup: &ComponentRc,
position: Point,
parent_item: &ItemRc
)
pub fn show_popup(
&self,
popup: &ComponentRc,
position: Point,
parent_item: &ItemRc
)
Show a popup at the given position relative to the item
sourcepub fn close_popup(&self)
pub fn close_popup(&self)
Removes any active popup.
sourcepub fn scale_factor(&self) -> f32
pub fn scale_factor(&self) -> f32
Returns the scale factor set on the window, as provided by the windowing system.
sourcepub fn scale_factor_property(&self) -> Pin<&Property<f32>>
pub fn scale_factor_property(&self) -> Pin<&Property<f32>>
Returns the scale factor set on the window, as provided by the windowing system.
sourcepub fn set_scale_factor(&self, factor: f32)
pub fn set_scale_factor(&self, factor: f32)
Sets the scale factor for the window. This is set by the backend or for testing.
sourcepub fn default_font_properties(&self) -> FontRequest
pub fn default_font_properties(&self) -> FontRequest
Returns the font properties that are set on the root item if it’s a Window item.
sourcepub fn set_window_item_geometry(&self, width: Coord, height: Coord)
pub fn set_window_item_geometry(&self, width: Coord, height: Coord)
Sets the size of the window item. This method is typically called in response to receiving a window resize event from the windowing system. Size is in logical pixels.
sourcepub fn on_close_requested(
&self,
callback: impl FnMut() -> CloseRequestResponse + 'static
)
pub fn on_close_requested(
&self,
callback: impl FnMut() -> CloseRequestResponse + 'static
)
Sets the close_requested callback. The callback will be run when the user tries to close a window.
sourcepub fn request_close(&self) -> bool
pub fn request_close(&self) -> bool
Runs the close_requested callback. If the callback returns KeepWindowShown, this function returns false. That should prevent the Window from closing. Otherwise it returns true, which allows the Window to hide.
Trait Implementations
sourceimpl Deref for Window
impl Deref for Window
type Target = dyn PlatformWindow + 'static
type Target = dyn PlatformWindow + 'static
The resulting type after dereferencing.
Auto Trait Implementations
impl !RefUnwindSafe for Window
impl !Send for Window
impl !Sync for Window
impl Unpin for Window
impl !UnwindSafe for Window
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more