giu: `giu.PopupModal()` does not work properly in some cases [bug]

What happend?

I’m using giu to make a simple widget, but I found that in table mode, PopupModal doesn’t work properly, I use the right mouse button to pop up the menu and select the action to do inside the menu, but when I click the button Post “PopupModal” not working!

Code example

package main

import (
	"github.com/AllenDang/giu"
	"wifi/giu/controller"
)

func loop() {
	giu.SingleWindow().Layout(
		giu.Column(
			giu.Row(
				giu.Table().Columns(
					giu.TableColumn("name"),
					giu.TableColumn("balance"),
				).Rows(
					giu.TableRow(
						giu.Selectable("locter"),
						giu.ContextMenu().Layout(
							giu.Button("about his").OnClick(func() {
								giu.CloseCurrentPopup()
								controller.ShowPopupModal()
							}),
						),
						giu.Selectable("$99.73"),
						giu.ContextMenu().Layout(
							giu.Button("refund").OnClick(func() {
								giu.CloseCurrentPopup()
								controller.ShowPopupModal()
							}),
						),
					),
				),
			),
		),
		giu.PopupModal("#PopupWindow").Layout(*controller.Layouts...),
	)
}

func main() {
	w := giu.NewMasterWindow("test", 400, 400, 0)
	w.Run(loop)
}
package controller

import (
	"github.com/AllenDang/giu"
	"time"
)

var Layouts = &giu.Layout{
	giu.Align(giu.AlignCenter).To(
		giu.Dummy(100, 1),
		giu.Labelf("time now: %v", time.Now().Format("2006-01-02")),
		giu.Button("clicked").OnClick(func() {
			giu.CloseCurrentPopup()
		}),
	),
}

func ShowPopupModal() {
	Layouts = &giu.Layout{
		giu.Align(giu.AlignCenter).To(
			giu.Dummy(100, 1),
			giu.Label("show~"),
			giu.Dummy(100, 8),
			giu.Button("return").OnClick(func() {
				giu.CloseCurrentPopup()
			}),
		),
	}

	giu.OpenPopup("#PopupWindow")
}

To Reproduce

  1. Run my demo
  2. will see that the popup is not working

Version

master

OS

Windows 11

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (1 by maintainers)

Most upvoted comments

ok, let me know if you have any issues okay, I just tested it and he worked correctly, thank you very much for your help

ok, let me know if you have any issues

He works in another test project I built, not yet in another big project, I’m troubleshooting the problem

You can check in exqmples/widgets. Iirc there was an pop-up modal impl I’ll review your code and write some demo for you later since in in bus at the moment and can’t write any code 😊

I have seen this, it is useless, this is the simplest example, what I do is a bit more complicated, I want him to right-click in the table to pop up a menu, and click a menu button to pop up a window