0.3.7 Got dialog return values. /JL
This commit is contained in:
Binary file not shown.
@@ -32,6 +32,11 @@ type (
|
|||||||
inStock bool
|
inStock bool
|
||||||
onHand int
|
onHand int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Retval struct {
|
||||||
|
Grams int
|
||||||
|
Number int
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func ShowBeads(mw *MyMainWindow, serie string) {
|
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)
|
img, _ := walk.NewImageFromFileForDPI("images/plus_alpha.png", 96)
|
||||||
color.add.SetImage(img)
|
color.add.SetImage(img)
|
||||||
color.add.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
|
color.add.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
|
||||||
var data Serie
|
var (
|
||||||
|
data Serie
|
||||||
|
ret = new(Retval)
|
||||||
|
)
|
||||||
if button == walk.LeftButton {
|
if button == walk.LeftButton {
|
||||||
for _, s := range color.Series {
|
for _, s := range color.Series {
|
||||||
if s.Name == mw.serie_combo.Text() {
|
if s.Name == mw.serie_combo.Text() {
|
||||||
data = *s
|
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)
|
color.info, err = walk.NewImageView(cm)
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import (
|
|||||||
"github.com/lxn/walk"
|
"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...")
|
log.Println("Adding beads...")
|
||||||
dlg, err := walk.NewDialog(mv.MainWindow)
|
dlg, err := walk.NewDialog(mv.MainWindow)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
log.Println(err)
|
||||||
}
|
}
|
||||||
dlg.SetTitle("Add Beads")
|
dlg.SetTitle("Add Beads")
|
||||||
dlg.SetLayout(walk.NewVBoxLayout())
|
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, _ := walk.NewPushButton(bc)
|
||||||
ab.SetText("Add")
|
ab.SetText("Add")
|
||||||
dlg.SetDefaultButton(ab)
|
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)
|
walk.NewHSpacer(bc)
|
||||||
cb, _ := walk.NewPushButton(bc)
|
cb, _ := walk.NewPushButton(bc)
|
||||||
cb.SetText("Cancel")
|
cb.SetText("Cancel")
|
||||||
dlg.SetCancelButton(cb)
|
dlg.SetCancelButton(cb)
|
||||||
|
cb.Clicked().Attach(func() {
|
||||||
|
dlg.Cancel()
|
||||||
|
})
|
||||||
|
|
||||||
dlg.Show()
|
return dlg.Run()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mw *MyMainWindow) openImage() error {
|
func (mw *MyMainWindow) openImage() error {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type MyMainWindow struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AppName string = "BeadImager"
|
AppName string = "BeadImager"
|
||||||
Version string = "0.3.6"
|
Version string = "0.3.7"
|
||||||
CopyRight string = "©2022 Jan Lerking"
|
CopyRight string = "©2022 Jan Lerking"
|
||||||
STD_MESS string = "Ready"
|
STD_MESS string = "Ready"
|
||||||
LogFile string = "BeadImager.log"
|
LogFile string = "BeadImager.log"
|
||||||
|
|||||||
Reference in New Issue
Block a user