0.3.7 Got dialog return values. /JL
This commit is contained in:
BIN
BeadImager.exe~
Normal file
BIN
BeadImager.exe~
Normal file
Binary file not shown.
13
color.go
13
color.go
@@ -32,6 +32,11 @@ type (
|
||||
inStock bool
|
||||
onHand int
|
||||
}
|
||||
|
||||
Retval struct {
|
||||
Grams int
|
||||
Number int
|
||||
}
|
||||
)
|
||||
|
||||
func ShowBeads(mw *MyMainWindow, serie string) {
|
||||
@@ -130,14 +135,18 @@ func NewBeadColor(mw *MyMainWindow, name string, id int, red byte, green byte, b
|
||||
img, _ := walk.NewImageFromFileForDPI("images/plus_alpha.png", 96)
|
||||
color.add.SetImage(img)
|
||||
color.add.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
|
||||
var data Serie
|
||||
var (
|
||||
data Serie
|
||||
ret = new(Retval)
|
||||
)
|
||||
if button == walk.LeftButton {
|
||||
for _, s := range color.Series {
|
||||
if s.Name == mw.serie_combo.Text() {
|
||||
data = *s
|
||||
}
|
||||
}
|
||||
mw.addBeads(name, data, color.ColorID, color.backgroundColor)
|
||||
val := mw.addBeads(name, data, color.ColorID, color.backgroundColor, ret)
|
||||
log.Println("Returned value: ", val)
|
||||
}
|
||||
})
|
||||
color.info, err = walk.NewImageView(cm)
|
||||
|
17
dialog.go
17
dialog.go
@@ -7,11 +7,11 @@ import (
|
||||
"github.com/lxn/walk"
|
||||
)
|
||||
|
||||
func (mv *MyMainWindow) addBeads(name string, data Serie, id int, bg walk.Brush) error {
|
||||
func (mv *MyMainWindow) addBeads(name string, data Serie, id int, bg walk.Brush, ret *Retval) int {
|
||||
log.Println("Adding beads...")
|
||||
dlg, err := walk.NewDialog(mv.MainWindow)
|
||||
if err != nil {
|
||||
return err
|
||||
log.Println(err)
|
||||
}
|
||||
dlg.SetTitle("Add Beads")
|
||||
dlg.SetLayout(walk.NewVBoxLayout())
|
||||
@@ -58,13 +58,22 @@ func (mv *MyMainWindow) addBeads(name string, data Serie, id int, bg walk.Brush)
|
||||
ab, _ := walk.NewPushButton(bc)
|
||||
ab.SetText("Add")
|
||||
dlg.SetDefaultButton(ab)
|
||||
ab.Clicked().Attach(func() {
|
||||
ret.Grams = int(le.Value())
|
||||
ret.Number = int(ne.Value())
|
||||
log.Println("grams:", ret.Grams)
|
||||
log.Println("number:", ret.Number)
|
||||
dlg.Accept()
|
||||
})
|
||||
walk.NewHSpacer(bc)
|
||||
cb, _ := walk.NewPushButton(bc)
|
||||
cb.SetText("Cancel")
|
||||
dlg.SetCancelButton(cb)
|
||||
cb.Clicked().Attach(func() {
|
||||
dlg.Cancel()
|
||||
})
|
||||
|
||||
dlg.Show()
|
||||
return nil
|
||||
return dlg.Run()
|
||||
}
|
||||
|
||||
func (mw *MyMainWindow) openImage() error {
|
||||
|
Reference in New Issue
Block a user