fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
223 stars 41 forks source link

Menu width not restored when making text narrower #66

Open kokororin opened 9 months ago

kokororin commented 9 months ago

Set the title of a menu to a longer character, then restore it. The width of the menu will not be restored.

image image image

minimal reproducible example:

package main

import (
    "fmt"
    "time"

    "fyne.io/systray"
    "fyne.io/systray/example/icon"
)

func main() {
    onExit := func() {
        now := time.Now()
        fmt.Println("Exit at", now.String())
    }

    systray.Run(onReady, onExit)
}

func addQuitItem() {
    mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
    mQuit.Enable()
    go func() {
        <-mQuit.ClickedCh
        fmt.Println("Requesting quit")
        systray.Quit()
        fmt.Println("Finished quitting")
    }()
    systray.AddSeparator()
}

func onReady() {
    systray.SetTemplateIcon(icon.Data, icon.Data)
    systray.SetTitle("Awesome App")
    systray.SetTooltip("Lantern")
    addQuitItem()

    // We can manipulate the systray in other goroutines
    go func() {
        systray.SetTitle("Awesome App")
        systray.SetTooltip("Pretty awesome棒棒嗒")
        mChange := systray.AddMenuItem("Change Me", "Change Me")
        mRestore := systray.AddMenuItem("Restore Me", "Restore Me")

        systray.AddMenuItem("Ignored", "Ignored")

        for {
            select {
            case <-mChange.ClickedCh:
                mChange.SetTitle("I've Changed, hahahahahaha")
            case <-mRestore.ClickedCh:
                mChange.SetTitle("Change Me")
            }
        }
    }()
}
Jacalz commented 9 months ago

On what operating system (and potentially desktop environment if on Linux/BSD) are you experiencing this?

Jacalz commented 9 months ago

I can't seem to replicate on Gnome. The menu is just as wide with both the narrow and wide texts (before and after).

kokororin commented 9 months ago

Windows 11