Letting the mouse pass through Windows Flutter
Asked Answered
W

1

8

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.

Wiser answered 12/2, 2022 at 23:25 Comment(8)
Use a layered window 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."Boudreau
I am not sure but 'WS_EX_TRANSPARENT' may be another option.Cyprus
WS_EX_TRANSPARENT won't do. Like the cake, WS_EX_TRANSPARENT is a lie, or at least not the entire truth.Boudreau
How I can get the hWnd inside flutter files ?Wiser
@Wiser You could refer to the thread: https://mcmap.net/q/832209/-flutter-windows-get-win32-window-handle-of-flutter-appKristof
@Wiser hey how do you solve this?Centaur
@ Manar Hidayat, you have two ways: you can use the window manager package: 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 eventWiser
@Wiser i used window_manager, and used IgnoreMouseEvents, but how to set IgnoreMouseEvents back to false?, because all the widget cannot clickCentaur
R
4

You can do it using the setIgnoreMouseEvents method of window_manager

https://github.com/leanflutter/window_manager

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

Ridinger answered 11/3, 2022 at 2:56 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.