lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.78k stars 885 forks source link

the StatusBar example doesn't display properly and HSplitter crashed when dragged #750

Closed zxjsameid closed 3 years ago

zxjsameid commented 3 years ago

The following is the main part of the code from the example directory on GitHub. To demonstrate the problem, I added a HSplitter code. There are two problems when running this Code:

(1) Initially, the status bar will not be displayed until the window size is adjusted

(2) HSplitter contains a widget with the attribute visible: false. After adjusting the size of the window, drag the handle near the edge of the window on the right side, and the program will exit abnormally. Sometimes the reason why I need to control the dynamic display of visible widget is that I need to set it.

Is there anyone who can help or encounter such problems? Thank you!

==== // Copyright 2017 The Walk Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.

// This example demonstrates the status bar, including a size gripper // attached to the bottom of the main window. // The status bar has two items, one is dynamically updated and one includes an icon. package main

import ( "github.com/lxn/walk" . "github.com/lxn/walk/declarative" )

func main() { // modified icon1 := walk.IconError() icon2 := walk.IconQuestion() // modified end

var sbi *walk.StatusBarItem

MainWindow{
    Title:   "Walk Statusbar Example",
    MinSize: Size{600, 200},
    Layout:  VBox{MarginsZero: true},

    // added
    Children: []Widget{
        HSplitter{
            HandleWidth: 10,
            Children: []Widget{
                TextEdit{},
                TextEdit{
                    Visible: false,
                },
            },
        },
    },
    // added end

    StatusBarItems: []StatusBarItem{
        StatusBarItem{
            AssignTo: &sbi,
            Icon:     icon1,
            Text:     "click",
            Width:    80,
            OnClicked: func() {
                if sbi.Text() == "click" {
                    sbi.SetText("again")
                    sbi.SetIcon(icon2)
                } else {
                    sbi.SetText("click")
                    sbi.SetIcon(icon1)
                }
            },
        },
        StatusBarItem{
            Text:        "left",
            ToolTipText: "no tooltip for me",
        },
        StatusBarItem{
            Text: "\tcenter",
        },
        StatusBarItem{
            Text: "\t\tright",
        },
        StatusBarItem{
            Icon:        icon1,
            ToolTipText: "An icon with a tooltip",
        },
    },
}.Run()

}

alkanna commented 3 years ago

I believe #747 fixes the first issue here, waiting on merge. I'm using it locally and it works nicely.

alkanna commented 3 years ago

This can be closed @lxn

zxjsameid commented 3 years ago

thank you!