diff --git a/BeadImager.exe~ b/BeadImager.exe~ new file mode 100644 index 0000000..353aa5e Binary files /dev/null and b/BeadImager.exe~ differ diff --git a/color.go b/color.go index 5224357..516790d 100644 --- a/color.go +++ b/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) diff --git a/dialog.go b/dialog.go index b202776..05991b6 100644 --- a/dialog.go +++ b/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 { diff --git a/main.go b/main.go index bc0c302..df4d010 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ type MyMainWindow struct { const ( AppName string = "BeadImager" - Version string = "0.3.6" + Version string = "0.3.7" CopyRight string = "©2022 Jan Lerking" STD_MESS string = "Ready" LogFile string = "BeadImager.log"