Created
November 11, 2020 20:40
-
-
Save shivas/59ad912e4c8a1150523096b9fa14fbcd to your computer and use it in GitHub Desktop.
ComboBox reproducible issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"syscall" | |
"time" | |
"github.com/lxn/walk" | |
. "github.com/lxn/walk/declarative" | |
) | |
type Config struct { | |
ClientWindowTitle string | |
} | |
type WindowComboBoxItem struct { | |
WindowTitle string | |
WindowHandle syscall.Handle | |
} | |
type TestWindow struct { | |
MainWindow *walk.MainWindow | |
DataBinder *walk.DataBinder | |
CaptureWindowComboBox *walk.ComboBox | |
} | |
func main() { | |
model := make([]*WindowComboBoxItem, 0) | |
model = append(model, &WindowComboBoxItem{WindowTitle: "title1", WindowHandle: 0}, &WindowComboBoxItem{WindowTitle: "title2", WindowHandle: 1}) | |
app := NewTestWindow(Config{}, model) | |
app.MainWindow.Run() | |
} | |
func NewTestWindow(config interface{}, comboBoxModel []*WindowComboBoxItem) *TestWindow { | |
obj := TestWindow{} | |
if err := (MainWindow{ | |
AssignTo: &obj.MainWindow, | |
Title: "ComboBox Test", | |
MinSize: Size{Width: 320, Height: 240}, | |
Size: Size{Width: 400, Height: 600}, | |
Layout: HBox{MarginsZero: false}, | |
DataBinder: DataBinder{ | |
AssignTo: &obj.DataBinder, | |
DataSource: config, | |
AutoSubmit: true, | |
AutoSubmitDelay: 1 * time.Second, | |
}, | |
Children: []Widget{ | |
Composite{ | |
Layout: HBox{}, | |
Children: []Widget{ | |
Composite{ | |
Layout: VBox{}, | |
Alignment: AlignHNearVNear, | |
Children: []Widget{ | |
GroupBox{ | |
Title: "Group settings", | |
Layout: VBox{}, | |
Children: []Widget{ | |
GroupBox{ | |
Title: "Capture region", | |
Layout: HBox{}, | |
Children: []Widget{ | |
ComboBox{ | |
AssignTo: &obj.CaptureWindowComboBox, | |
Model: comboBoxModel, | |
ToolTipText: "Client to capture", | |
BindingMember: "WindowTitle", | |
DisplayMember: "WindowTitle", | |
Value: Bind("ClientWindowTitle"), | |
OnCurrentIndexChanged: func() { | |
fmt.Printf("On index change triggered: %v", obj.CaptureWindowComboBox.CurrentIndex()) | |
}, | |
Editable: false, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}.Create()); err != nil { | |
log.Fatal(err) | |
} | |
return &obj | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment