antler119 / system_tray

A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.
MIT License
214 stars 51 forks source link

Question: Open menu on left click #15

Closed mehmetyilmaz001 closed 2 years ago

mehmetyilmaz001 commented 2 years ago

Hi,

Is there any way to show context menu when click left mouse button.

Thnx

LucianoLaratelli commented 2 years ago

Hey, I saw this problem as well. You can apply this change for macOS:

@objc func on_system_tray_event_callback(sender: NSStatusBarButton) {
    if let event = NSApp.currentEvent {
        switch event.type {
        // case .leftMouseUp:
        //     channel.invokeMethod(kSystemTrayEventCallbackMethod, arguments: kSystemTrayEventLButtnUp)
        default:
            channel.invokeMethod(kSystemTrayEventCallbackMethod, arguments: kSystemTrayEventRButtnUp)

            statusItem?.menu = statusItemMenu
            statusItem?.button?.performClick(nil)
        }
    }
}

I haven't poked around the Windows code yet but I'm assuming there's a similar fix that can be applied.

LucianoLaratelli commented 2 years ago

Threw a slightly different fix for mac and windows into a fork: https://github.com/LucianoLaratelli/system_tray

Haven't looked at Linux yet

LucianoLaratelli commented 2 years ago

Looks like this might be a better replacement: https://github.com/leanflutter/tray_manager

antler119 commented 2 years ago

pls try v0.0.9