Skip to main content

WindowExt

Trait WindowExt 

Source
pub trait WindowExt: Sized {
Show 20 methods // Required methods fn open_sheet<F>(&mut self, cx: &mut App, build: F) where F: Fn(Sheet, &mut Window, &mut App) -> Sheet + 'static; fn open_sheet_at<F>(&mut self, placement: Placement, cx: &mut App, build: F) where F: Fn(Sheet, &mut Window, &mut App) -> Sheet + 'static; fn has_active_sheet(&mut self, cx: &mut App) -> bool; fn close_sheet(&mut self, cx: &mut App); fn open_dialog<F>(&mut self, cx: &mut App, build: F) where F: Fn(Dialog, &mut Window, &mut App) -> Dialog + 'static; fn open_alert_dialog<F>(&mut self, cx: &mut App, build: F) where F: Fn(AlertDialog, &mut Window, &mut App) -> AlertDialog + 'static; fn has_active_dialog(&mut self, cx: &mut App) -> bool; fn close_dialog(&mut self, cx: &mut App); fn close_all_dialogs(&mut self, cx: &mut App); fn push_notification(&mut self, note: impl Into<Notification>, cx: &mut App); fn remove_notification<T: Sized + 'static>(&mut self, cx: &mut App); fn remove_notification1<T: Sized + 'static>( &mut self, key: impl Into<ElementId>, cx: &mut App, ); fn clear_notifications(&mut self, cx: &mut App); fn notifications(&mut self, cx: &mut App) -> Rc<Vec<Entity<Notification>>>; fn focused_input(&mut self, cx: &mut App) -> Option<AnyInputState>; fn has_focused_input(&mut self, cx: &mut App) -> bool; fn selected_text(&mut self, cx: &mut App) -> String; fn has_text_selection(&mut self, cx: &mut App) -> bool; fn clear_text_selection(&mut self, cx: &mut App); fn end_text_selection(&mut self, cx: &mut App);
}
Expand description

Extension trait for Window to add dialog, sheet .. functionality.

Required Methods§

Source

fn open_sheet<F>(&mut self, cx: &mut App, build: F)
where F: Fn(Sheet, &mut Window, &mut App) -> Sheet + 'static,

Opens a Sheet at right placement.

Source

fn open_sheet_at<F>(&mut self, placement: Placement, cx: &mut App, build: F)
where F: Fn(Sheet, &mut Window, &mut App) -> Sheet + 'static,

Opens a Sheet at the given placement.

Source

fn has_active_sheet(&mut self, cx: &mut App) -> bool

Return true, if there is an active Sheet.

Source

fn close_sheet(&mut self, cx: &mut App)

Closes the active Sheet.

Source

fn open_dialog<F>(&mut self, cx: &mut App, build: F)
where F: Fn(Dialog, &mut Window, &mut App) -> Dialog + 'static,

Opens a Dialog.

Source

fn open_alert_dialog<F>(&mut self, cx: &mut App, build: F)
where F: Fn(AlertDialog, &mut Window, &mut App) -> AlertDialog + 'static,

Opens an AlertDialog.

This is a convenience method for opening an alert dialog with opinionated defaults. The footer buttons are center-aligned and include an icon based on the variant.

§Examples
use gpui_kit::component::{AlertDialog, alert::AlertVariant};

window.open_alert_dialog(cx, |alert, _, _| {
    alert.warning()
        .title("Unsaved Changes")
        .description("You have unsaved changes. Are you sure you want to leave?")
        .show_cancel(true)
});
Source

fn has_active_dialog(&mut self, cx: &mut App) -> bool

Return true, if there is an active Dialog.

Source

fn close_dialog(&mut self, cx: &mut App)

Closes the last active Dialog.

Source

fn close_all_dialogs(&mut self, cx: &mut App)

Closes all active Dialogs.

Source

fn push_notification(&mut self, note: impl Into<Notification>, cx: &mut App)

Pushes a notification to the notification list.

Source

fn remove_notification<T: Sized + 'static>(&mut self, cx: &mut App)

Removes all notifications whose id matches T, including ones registered with either Notification::id or Notification::id1 (any key).

Source

fn remove_notification1<T: Sized + 'static>( &mut self, key: impl Into<ElementId>, cx: &mut App, )

Removes a single notification matching the given type T and key (paired with Notification::id1).

Source

fn clear_notifications(&mut self, cx: &mut App)

Clears all notifications.

Source

fn notifications(&mut self, cx: &mut App) -> Rc<Vec<Entity<Notification>>>

Returns number of notifications.

Source

fn focused_input(&mut self, cx: &mut App) -> Option<AnyInputState>

Return the currently focused input state.

Covers Input, Textarea, Editor and OtpInput, use AnyInputState::as_input and friends to get the concrete state. A registration whose focus handle is no longer focused (e.g. the input was removed from the tree while focused) is treated as None.

Source

fn has_focused_input(&mut self, cx: &mut App) -> bool

Returns true if there is a focused Input entity.

Source

fn selected_text(&mut self, cx: &mut App) -> String

👎Deprecated:

use gpui_base::TextSelection::selected_text instead

Returns the merged selected text across registered selectable regions in this window, in logical document order and joined with \n.

Source

fn has_text_selection(&mut self, cx: &mut App) -> bool

👎Deprecated:

use gpui_base::TextSelection::has_selection instead

Returns true if any registered region has an active text selection in this window, including renderer-local selections such as select-all.

Source

fn clear_text_selection(&mut self, cx: &mut App)

👎Deprecated:

use gpui_base::TextSelection::clear instead

Clears the window text selection and all registered renderer-local selections.

Source

fn end_text_selection(&mut self, cx: &mut App)

👎Deprecated:

use gpui_base::TextSelection::end instead

Ends the in-progress window-level text selection drag (if any).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl WindowExt for Window

Source§

fn open_sheet<F>(&mut self, cx: &mut App, build: F)
where F: Fn(Sheet, &mut Window, &mut App) -> Sheet + 'static,

Source§

fn open_sheet_at<F>(&mut self, placement: Placement, cx: &mut App, build: F)
where F: Fn(Sheet, &mut Window, &mut App) -> Sheet + 'static,

Source§

fn has_active_sheet(&mut self, cx: &mut App) -> bool

Source§

fn close_sheet(&mut self, cx: &mut App)

Source§

fn open_dialog<F>(&mut self, cx: &mut App, build: F)
where F: Fn(Dialog, &mut Window, &mut App) -> Dialog + 'static,

Source§

fn open_alert_dialog<F>(&mut self, cx: &mut App, build: F)
where F: Fn(AlertDialog, &mut Window, &mut App) -> AlertDialog + 'static,

Source§

fn has_active_dialog(&mut self, cx: &mut App) -> bool

Source§

fn close_dialog(&mut self, cx: &mut App)

Source§

fn close_all_dialogs(&mut self, cx: &mut App)

Source§

fn push_notification(&mut self, note: impl Into<Notification>, cx: &mut App)

Source§

fn remove_notification<T: Sized + 'static>(&mut self, cx: &mut App)

Source§

fn remove_notification1<T: Sized + 'static>( &mut self, key: impl Into<ElementId>, cx: &mut App, )

Source§

fn clear_notifications(&mut self, cx: &mut App)

Source§

fn notifications(&mut self, cx: &mut App) -> Rc<Vec<Entity<Notification>>>

Source§

fn has_focused_input(&mut self, cx: &mut App) -> bool

Source§

fn focused_input(&mut self, cx: &mut App) -> Option<AnyInputState>

Source§

fn selected_text(&mut self, cx: &mut App) -> String

👎Deprecated:

use gpui_base::TextSelection::selected_text instead

Source§

fn has_text_selection(&mut self, cx: &mut App) -> bool

👎Deprecated:

use gpui_base::TextSelection::has_selection instead

Source§

fn clear_text_selection(&mut self, cx: &mut App)

👎Deprecated:

use gpui_base::TextSelection::clear instead

Source§

fn end_text_selection(&mut self, cx: &mut App)

👎Deprecated:

use gpui_base::TextSelection::end instead

Implementors§