db: return error from contextAction.Callback (2)
This commit is contained in:
parent
1ac96eb133
commit
8f5e1054fb
@ -151,7 +151,7 @@ func (ld *boltLoadedDatabase) NavContext(ndata *navData) (ret []contextAction, e
|
||||
return
|
||||
}
|
||||
|
||||
func (ld *boltLoadedDatabase) AddChildBucket(ndata *navData) error {
|
||||
func (ld *boltLoadedDatabase) AddChildBucket(sender vcl.IComponent, ndata *navData) error {
|
||||
bucketName := ""
|
||||
if !vcl.InputQuery(APPNAME, "Enter a name for the new bucket:", &bucketName) {
|
||||
return nil // cancel
|
||||
@ -174,7 +174,7 @@ func (ld *boltLoadedDatabase) AddChildBucket(ndata *navData) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ld *boltLoadedDatabase) DeleteBucket(ndata *navData) error {
|
||||
func (ld *boltLoadedDatabase) DeleteBucket(sender vcl.IComponent, ndata *navData) error {
|
||||
err := ld.db.Update(func(tx *bbolt.Tx) error {
|
||||
// Find parent of this bucket.
|
||||
if len(ndata.bucketPath) >= 2 {
|
||||
|
@ -11,7 +11,7 @@ var ErrNotSupported error = errors.New("Unsupported action for this database typ
|
||||
|
||||
type contextAction struct {
|
||||
Name string
|
||||
Callback func(ndata *navData) error
|
||||
Callback func(sender vcl.IComponent, ndata *navData) error
|
||||
}
|
||||
|
||||
// loadedDatabase is a DB-agnostic interface for each loaded database.
|
||||
|
2
main.go
2
main.go
@ -507,7 +507,7 @@ func (f *TMainForm) OnNavContextPopup(sender vcl.IObject, mousePos types.TPoint,
|
||||
mnuAction.SetCaption(action.Name)
|
||||
cb := action.Callback // Copy to avoid reuse of loop variable
|
||||
mnuAction.SetOnClick(func(sender vcl.IObject) {
|
||||
err = cb(ndata)
|
||||
err = cb(f, ndata)
|
||||
if err != nil {
|
||||
vcl.ShowMessage(err.Error())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user