ahkohd / tauri-macos-spotlight-example

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

Can not Display Input Method Editor in Window #8

Closed zhouyangtingwen closed 1 year ago

zhouyangtingwen commented 1 year ago

Hello, thank you very much for your project, which has helped me a lot, but I have a question to ask you. When I try to type in < INPUT >, my input method editor cannot be displayed on the window.

zhouyangtingwen commented 1 year ago

11361686389133_ pic Just like Raycast.

zhouyangtingwen commented 1 year ago

image Input Method Editor works well on your window, but it cannot be displayed

zhouyangtingwen commented 1 year ago

Looking forward to hearing from you, Many thanks🙏.

ahkohd commented 1 year ago

I'm afraid I don't understand you. Can you provide a screen recording and elaborate more on the problem?

zhouyangtingwen commented 1 year ago

Excuse me, can this problem be solved?

ahkohd commented 1 year ago

Apologies for my delayed response. I wasn't aware of this macOS feature. Could you kindly guide me on how to set it up? I'm eager to troubleshoot the issue. My hunch is that the Panel window level may be higher than that of the Input Method Editor.

zhouyangtingwen commented 1 year ago

Thank you very much. I solved the problem of input method. But now there is another question: Does the window support corner radius? Look forward to your reply. Thank you very much. @ahkohd

ahkohd commented 1 year ago

You can add the implementation below here: https://github.com/ahkohd/tauri-macos-spotlight-example/blob/c5507f5e28c6ac1a1e9bca3e28897efe63e2c37a/src-tauri/src/spotlight.rs#L305

The implementation should roughly look like this:

  fn set_corner_radius(&self, radius: f64) {
        let content_view: id = unsafe { msg_send![self, contentView] };
        let _: () = unsafe  { msg_send![content_view, wantsLayer] };
        let layer: id = unsafe { msg_send![content_view, layer] };
        let _: () = unsafe { msg_send![layer, setCornerRadius: radius] };
    }

the usage:

panel.set_corner_radius(12.0);
ahkohd commented 1 year ago

@zhouyangtingwen Will you close this issue? Please explain how to fix this issue so others can learn.

zhouyangtingwen commented 1 year ago

@ahkohd Thank you very much🙏🙏. I will.👌

zhouyangtingwen commented 1 year ago

Before I finish this question, may I ask you one last question? Now, when the focus leaves the NSPanel window, the NSPanel window will be hidden. How to prevent the NSPanel from being hidden when the focus leaves the NSPanel window? @ahkohd

trymbill commented 1 year ago

How to prevent the NSPanel from being hidden when the focus leaves the NSPanel window?

Did you ever figure out how to accomplish that? I'm wondering how to listen for windowWillClose or something similar, in order to update a different part of an app when the user clicks outside of the NSPanel window. Do you know of a good way to accomplish that @ahkohd ?

ahkohd commented 1 year ago

Before I finish this question, may I ask you one last question? Now, when the focus leaves the NSPanel window, the NSPanel window will be hidden. How to prevent the NSPanel from being hidden when the focus leaves the NSPanel window? @ahkohd

https://github.com/ahkohd/tauri-macos-spotlight-example/issues/9#issuecomment-1673887324

ahkohd commented 1 year ago

How to prevent the NSPanel from being hidden when the focus leaves the NSPanel window?

Did you ever figure out how to accomplish that? I'm wondering how to listen for windowWillClose or something similar, in order to update a different part of an app when the user clicks outside of the NSPanel window. Do you know of a good way to accomplish that @ahkohd ?

You should probably use the Tauri plugin I created., use it to listen to the window_did_resign event, which fires when the window resigns.

let app_handle: tauri::AppHandle = ....

let delegate = panel_delegate!(MyPanelDelegate {
  window_did_become_key,
  window_did_resign_key
});

// Listen to when a delegate is called
delegate.set_listener(Box::new(move |delegate_name: String| {
    println!("{} was called!", delegate_name);
   // See, https://developer.apple.com/documentation/appkit/nswindowdelegate?language=objc
   // for an exhaustive list of delegate events. 
   // emit an event to your window
   if delegate_name == "window_did_resign" {
      app_handle.get_window("some_window").emit("event_name", ());
   }
}));
ahkohd commented 1 year ago

@zhouyangtingwen can we close this issue?

zhouyangtingwen commented 1 year ago

@zhouyangtingwen can we close this issue?

Sure

wangqiaobook commented 4 months ago

image Input Method Editor works well on your window, but it cannot be displayed

Hello, have you solved this problem? How did you solve it?