ahkohd / tauri-macos-spotlight-example

An example macOS Spotlight app built with Tauri
MIT License
148 stars 9 forks source link

Resizeable Window #10

Closed iceener closed 1 year ago

iceener commented 1 year ago

Hey! 👋

I need to make this window resizable, but whenever I try to do it, the window stops appearing on top of fullscreen apps.

Do you have any ideas how to implement this?

Solved, I guess. The solution below seems to work.

  1. Extend RawNSPanel with this method:

    fn set_resizable(&self) {
    let current_style_mask: NSWindowStyleMask = unsafe { msg_send![self, styleMask] };
    let new_style_mask = current_style_mask | NSWindowStyleMask::NSWindowStyleMaskResizable;
    self.set_style_mask(new_style_mask.bits() as i32);
    }
  2. Update init method

#[tauri::command]
pub fn init_spotlight_window(app_handle: AppHandle<Wry>, window: Window<Wry>) {
    INIT.call_once(|| {
        let panel = create_spotlight_panel(&window);
        set_state!(app_handle, panel, Some(create_spotlight_panel(&window)));
        panel.set_resizable();
        register_shortcut(app_handle);
    });
}
ahkohd commented 1 year ago

Cool, glad you solved it yourself!