7

I am working on a Flutter Desktop screen Annotation Application where I want to ignore the mouse events and let is pass through the window (so I can click on desktop application shortcut) when the icon(Red Box) Activated, and ignore it when one of the options in the blue box is activated. I am using flutter_acrylic to make the window transparent, and I know that I should use win32 to handle this functionality. but I really don't know the way to do that :(enter image description here

Thanks in advance for the help.

Anas-Qasem
  • 185
  • 10
  • 4
    Use a [layered window](https://learn.microsoft.com/en-us/windows/win32/winmsg/window-features#layered-windows) instead: *"Hit testing of a layered window is based on the shape and transparency of the window. This means that the areas of the window that are color-keyed or **whose alpha value is zero will let the mouse messages through**."* – IInspectable Feb 13 '22 at 08:19
  • I am not sure but 'WS_EX_TRANSPARENT' may be another option. – jtxkopt Feb 13 '22 at 08:26
  • `WS_EX_TRANSPARENT` won't do. [Like the cake, WS_EX_TRANSPARENT is a lie, or at least not the entire truth](https://devblogs.microsoft.com/oldnewthing/20121217-00/?p=5823). – IInspectable Feb 13 '22 at 08:52
  • How I can get the hWnd inside flutter files ? – Anas-Qasem Feb 13 '22 at 10:20
  • @Anas-Qasem You could refer to the thread: https://stackoverflow.com/a/59440034/11872808 – Jeaninez - MSFT Feb 16 '22 at 08:02
  • @Anas-Qasem hey how do you solve this? – Manar Hidayat Mar 30 '23 at 03:25
  • @ Manar Hidayat, you have two ways: you can use the window manager package: https://pub.dev/packages/window_manager which already has the option to ignore the mouse event for your app window or use win32 which allows you to use the native win32 function inside flutter like SetWindowLongPtr and SetLayeredWindowAttributes that allow you to ignore the mouse event – Anas-Qasem Mar 30 '23 at 09:25
  • @Anas-Qasem i used window_manager, and used IgnoreMouseEvents, but how to set IgnoreMouseEvents back to false?, because all the widget cannot click – Manar Hidayat Apr 03 '23 at 03:38

1 Answers1

4

You can do it using the setIgnoreMouseEvents method of window_manager

https://github.com/leanflutter/window_manager

https://twitter.com/lijy91/status/1502115704677433353

lijy91
  • 311
  • 4
  • 3