Skip to content

[v3] Event emitter blocks menu button press #4424

@COD3HUNT3R

Description

@COD3HUNT3R

Description

After the first event emit About button in below example no longer works. If I remove/comment out the goroutine to emit events button works as expected.

// Create a goroutine that emits an event containing the current time every second.
	// The frontend can listen to this event and update the UI accordingly.
	go func() {
		for {
			ps, err := monitor.GetProcesses()
			if err != nil {
				log.Fatal(err)
			}
			app.Event.Emit("ps", ps)
			time.Sleep(3 * time.Second)
		}
	}()

menu := app.NewMenu()
	helpMenu := menu.AddSubmenu("Help")
	about := helpMenu.Add("About")

	about.OnClick(func(ctx *application.Context) {
		log.Println("ok")
		notifier.SendNotification(notifications.NotificationOptions{
			ID:       "unique-id",
			Title:    "New Calendar Invite",
			Subtitle: "From: Jane Doe", // Optional
			Body:     "Tap to view the event",
			Data: map[string]interface{}{
				"sender":    "jane.doe@example.com",
				"timestamp": "2025-03-10T15:30:00Z",
			},
		})
		//dialog := application.InfoDialog()
		//dialog.SetTitle("Welcome")
		//dialog.SetMessage("Welcome to our application!")
		//dialog.SetMessage("Welcome to our application!")
		//dialog.Show()
		app.Menu.ShowAbout()
	})

// Create a new window with the necessary options.
	// 'Title' is the title of the window.
	// 'Mac' options tailor the window when running on macOS.
	// 'BackgroundColour' is the background colour of the window.
	// 'URL' is the URL that will be loaded into the webview.
	window := app.Window.NewWithOptions(application.WebviewWindowOptions{
		Title: "Window 1",
		Mac: application.MacWindow{
			InvisibleTitleBarHeight: 50,
			Backdrop:                application.MacBackdropTranslucent,
			TitleBar:                application.MacTitleBarHiddenInset,
		},
		// BackgroundColour: application.NewRGB(27, 38, 54),
		URL: "/",
	})
	window.SetMenu(menu)

To Reproduce

Try the above example

Expected behaviour

Event emitter should not block menu button press.

Screenshots

No response

Attempted Fixes

No response

System Details

Wails (v3.0.0-alpha.11)  Wails Doctor

# System

┌─────────────────────────────────────────────────────────────────────┐
| Name         | Fedora Linux                                         |
| Version      | 42                                                   |
| ID           | fedora                                               |
| Branding     | 42 (Workstation Edition)                             |
| Platform     | linux                                                |
| Architecture | amd64                                                |
| CPU 1        | Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)             |
| CPU 2        | Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)             |
| CPU 3        | Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)             |
| CPU 4        | Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)             |
| GPU 1        | Virtio 1.0 GPU (Red Hat, Inc.) - Driver: virtio-pci  |
| Memory       | 17GB                                                 |
└─────────────────────────────────────────────────────────────────────┘

# Build Environment

┌────────────────────────────────┐
| Wails CLI    | v3.0.0-alpha.11 |
| Go Version   | go1.24.4        |
| -buildmode   | exe             |
| -compiler    | gc              |
| CGO_CFLAGS   |                 |
| CGO_CPPFLAGS |                 |
| CGO_CXXFLAGS |                 |
| CGO_ENABLED  | 1               |
| CGO_LDFLAGS  |                 |
| GOAMD64      | v1              |
| GOARCH       | amd64           |
| GOOS         | linux           |
└────────────────────────────────┘

# Dependencies

┌───────────────────────────┐
| gcc        | 15.0.1       |
| gtk3       | 3.24.49      |
| npm        | 10.9.2       |
| pkg-config | 2.3.0        |
| webkit2gtk | 2.48.3       |
|                           |
└─ * - Optional Dependency ─┘

# Checking for issues

 SUCCESS  No issues found

# Diagnosis

 SUCCESS  Your system is ready for Wails development!

Need documentation? Run: wails3 docs
 ♥   If Wails is useful to you or your company, please consider sponsoring the project: wails3 sponsor

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingLinuxv3

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions