gonutz / wui

Windows GUI library for Go (Golang). Comes with a graphical UI designer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error after triggering by pressing button modal window on secont time

bogus43 opened this issue · comments

Hi, I have main window in my application and modal window, which are trigered by pressing button. I use ShowModal() method to show modal window and Close() method to close this window. It is working fine for first time I use, but when I hit button second time or more to show modal window it returning error -"window already visible". It seems I am doing something wrong Closing this window, but I really have no idea what exactly. Could you help me (again :) )

Can you post the code, or better yet a minimal sample that reproduces the issue?

package main

import (
	"fmt"

	"github.com/gonutz/wui/v2"
)

func main() {

	windowFont, _ := wui.NewFont(wui.FontDesc{
		Name:   "Tahoma",
		Height: -11,
	})

	window := wui.NewWindow()
	window.SetFont(windowFont)
	window.SetTitle("Window")

	button1 := wui.NewButton()
	button1.SetBounds(187, 278, 156, 78)
	button1.SetText("Show Modal Window")
	window.Add(button1)

	//Modal window
	ModalWindow := wui.NewWindow()
	ModalWindow.SetFont(windowFont)
	ModalWindow.SetTitle("Modal Window")

	closeBtn := wui.NewButton()
	closeBtn.SetBounds(187, 178, 156, 78)
	closeBtn.SetText("Close")
	ModalWindow.Add(closeBtn)

	//Event for show modal window
	button1.SetOnClick(func() {
		err := ModalWindow.ShowModal()
		if err != nil {
			fmt.Println(err)
		}
	})
	//event for close modal window
	closeBtn.SetOnClick(func() {
		ModalWindow.Close()
	})

	window.Show()
}

Hi, any idea what is wrong with above code?

Yes, this is a problem at the top of the Show and ShowModal functions where the old window handle is checked to see if a window exists. The problem is really not that it is already visible - because it is obvioulsy not - but that it is not flagged as closed. I need to have a different way for that to work. But again, I do not have the time to work on wui at the moment, unfortunately.

Thank you for your reply, I hope you will find a free moment and can solve this problem :)

Hi, I hope You are doing well. Any update related to this topic?

No, still no time left in the day :-)

Hi, any update with bug?

Nope, yet again I have had no time to continue working on this. Sorry :-)

Hello, any update?

Actually yes, I have started working on a v3 of wui. One of the problems in the current design is the way Show and ShowModal work, so it will address this issue directly, among others. I have no concrete time frame for when I push it, but work has started and I guess that at some point in my life-time I will push it. That is as much as I can promise, I am afraid ;-)

Thank You. I am looking forward for v3 :).