pub struct WindowInner {
pub focus_item: RefCell<ItemWeak>,
/* private fields */
}
Expand description
Inner datastructure for the crate::api::Window
Fields§
§focus_item: RefCell<ItemWeak>
ItemRC that currently have the focus. (possibly a, instance of TextInput)
Implementations§
Source§impl WindowInner
impl WindowInner
Sourcepub fn new(window_adapter_weak: Weak<dyn WindowAdapter>) -> Self
pub fn new(window_adapter_weak: Weak<dyn WindowAdapter>) -> Self
Create a new instance of the window, given the window_adapter factory fn
Sourcepub fn set_component(&self, component: &ItemTreeRc)
pub fn set_component(&self, component: &ItemTreeRc)
Associates this window with the specified component. Further event handling and rendering, etc. will be done with that component.
Sourcepub fn component(&self) -> ItemTreeRc
pub fn component(&self) -> ItemTreeRc
return the component. Panics if it wasn’t set.
Sourcepub fn try_component(&self) -> Option<ItemTreeRc>
pub fn try_component(&self) -> Option<ItemTreeRc>
returns the component or None if it isn’t set.
Sourcepub fn process_mouse_input(&self, event: MouseEvent)
pub fn process_mouse_input(&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, event: KeyEvent)
pub fn process_key_input(&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, new_focus_item: &ItemRc, set_focus: bool)
pub fn set_focus_item(&self, new_focus_item: &ItemRc, set_focus: bool)
Sets the focus to the item pointed to by item_ptr. This will remove the focus from any currently focused item. If set_focus is false, the focus is cleared.
Sourcepub fn focus_next_item(&self)
pub fn focus_next_item(&self)
Move keyboard focus to the next item
Sourcepub fn focus_previous_item(&self)
pub fn focus_previous_item(&self)
Move keyboard focus to the previous item.
Sourcepub fn set_active(&self, have_focus: bool)
pub fn set_active(&self, have_focus: 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.
This results in WindowFocusReceived and WindowFocusLost events.
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<T>(
&self,
render_components: impl FnOnce(&[(&ItemTreeRc, LogicalPoint)]) -> T,
) -> Option<T>
pub fn draw_contents<T>( &self, render_components: impl FnOnce(&[(&ItemTreeRc, LogicalPoint)]) -> T, ) -> Option<T>
Calls the render_components to render the main component and any sub-window components, tracked by a property dependency tracker. Returns None if no component is set yet.
Sourcepub fn show(&self) -> Result<(), PlatformError>
pub fn show(&self) -> Result<(), PlatformError>
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 hide(&self) -> Result<(), PlatformError>
pub fn hide(&self) -> Result<(), PlatformError>
De-registers the window with the windowing system.
Sourcepub fn color_scheme(&self) -> ColorScheme
pub fn color_scheme(&self) -> ColorScheme
returns the color theme used
Sourcepub fn show_popup(
&self,
popup_componentrc: &ItemTreeRc,
position: LogicalPosition,
close_policy: PopupClosePolicy,
parent_item: &ItemRc,
) -> NonZeroU32
pub fn show_popup( &self, popup_componentrc: &ItemTreeRc, position: LogicalPosition, close_policy: PopupClosePolicy, parent_item: &ItemRc, ) -> NonZeroU32
Show a popup at the given position relative to the item and returns its ID. The returned ID will always be non-zero.
Attempt to show a native popup menu
context_menu_item is an instance of a ContextMenu
Returns false if the native platform doesn’t support it
Sourcepub fn close_popup(&self, popup_id: NonZeroU32)
pub fn close_popup(&self, popup_id: NonZeroU32)
Removes the popup matching the given ID.
Sourcepub fn close_all_popups(&self)
pub fn close_all_popups(&self)
Close all active popups.
Sourcepub fn close_top_popup(&self)
pub fn close_top_popup(&self)
Close the top-most popup.
Sourcepub fn top_close_policy(&self) -> PopupClosePolicy
pub fn top_close_policy(&self) -> PopupClosePolicy
Returns the close policy of the top-most popup. PopupClosePolicy::NoAutoClose if there is no 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 text_input_focused(&self) -> bool
pub fn text_input_focused(&self) -> bool
Reads the global property TextInputInterface.text-input-focused
Sourcepub fn set_text_input_focused(&self, value: bool)
pub fn set_text_input_focused(&self, value: bool)
Sets the global property TextInputInterface.text-input-focused
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Returns true if the window is visible
Sourcepub fn window_item(&self) -> Option<VRcMapped<ItemTreeVTable, WindowItem>>
pub fn window_item(&self) -> Option<VRcMapped<ItemTreeVTable, WindowItem>>
Returns the window item that is the first item in the component.
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.
Sourcepub fn is_fullscreen(&self) -> bool
pub fn is_fullscreen(&self) -> bool
Returns if the window is currently maximized
Sourcepub fn set_fullscreen(&self, enabled: bool)
pub fn set_fullscreen(&self, enabled: bool)
Set or unset the window to display fullscreen.
Sourcepub fn is_maximized(&self) -> bool
pub fn is_maximized(&self) -> bool
Returns if the window is currently maximized
Sourcepub fn set_maximized(&self, maximized: bool)
pub fn set_maximized(&self, maximized: bool)
Set the window as maximized or unmaximized
Sourcepub fn is_minimized(&self) -> bool
pub fn is_minimized(&self) -> bool
Returns if the window is currently minimized
Sourcepub fn set_minimized(&self, minimized: bool)
pub fn set_minimized(&self, minimized: bool)
Set the window as minimized or unminimized
Sourcepub fn xdg_app_id(&self) -> Option<SharedString>
pub fn xdg_app_id(&self) -> Option<SharedString>
Returns the (context global) xdg app id for use with wayland and x11.
Sourcepub fn window_adapter(&self) -> Rc<dyn WindowAdapter>
pub fn window_adapter(&self) -> Rc<dyn WindowAdapter>
Returns the upgraded window adapter
Sourcepub fn from_pub(window: &Window) -> &Self
pub fn from_pub(window: &Window) -> &Self
Private access to the WindowInner for a given window.
Sourcepub fn context(&self) -> &SlintContext
pub fn context(&self) -> &SlintContext
Provides access to the Windows’ Slint context.