Skip to content

Commit 098f1d7

Browse files
committed
BindClickedHook gets the binder
1 parent d21aebd commit 098f1d7

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

core/bind_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func TestBind_Hook_Clicked_binding(t *testing.T) {
263263
gotElem := &Element{}
264264
gotName := ""
265265
bind := Bind(&mu, &val).
266-
Clicked(func(elem *Element, name string) (err error) {
266+
Clicked(func(bind Binder[string], elem *Element, name string) (err error) {
267267
calls++
268268
gotElem = elem
269269
gotName = name
@@ -305,11 +305,11 @@ func TestBind_Hook_Clicked_bindingHook(t *testing.T) {
305305

306306
clickCalls1 := 0
307307
clickCalls2 := 0
308-
clickBind1 := bindWithSuccess.Clicked(func(*Element, string) error {
308+
clickBind1 := bindWithSuccess.Clicked(func(Binder[string], *Element, string) error {
309309
clickCalls1++
310310
return nil
311311
})
312-
clickBind2 := clickBind1.Clicked(func(*Element, string) error {
312+
clickBind2 := clickBind1.Clicked(func(Binder[string], *Element, string) error {
313313
clickCalls2++
314314
return nil
315315
})
@@ -369,12 +369,12 @@ func TestBind_Hook_Clicked_bindingHook_fallsThroughUnhandled(t *testing.T) {
369369
clickCalls1 := 0
370370
clickCalls2 := 0
371371
clickBind2 := Bind(&mu, &val).
372-
Clicked(func(*Element, string) error {
372+
Clicked(func(Binder[string], *Element, string) error {
373373
clickCalls1++
374374
order = append(order, 1)
375375
return ErrEventUnhandled
376376
}).
377-
Clicked(func(*Element, string) error {
377+
Clicked(func(Binder[string], *Element, string) error {
378378
clickCalls2++
379379
order = append(order, 2)
380380
return nil

core/binder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type BindGetHook[T comparable] func(bind Binder[T], elem *Element) (value T)
2121
// BindClickedHook is a function to call when a click event is received.
2222
//
2323
// The Binder locks are not held when the function is called.
24-
type BindClickedHook[T comparable] func(elem *Element, name string) (err error)
24+
type BindClickedHook[T comparable] func(bind Binder[T], elem *Element, name string) (err error)
2525

2626
// BindSuccessHook is a function to call when a call to JawsSet returns with no error.
2727
//

core/bindinghook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func callChain[T comparable](binder Binder[T], elem *Element, kind callChainType
6565
case callChainClicked:
6666
if err == ErrEventUnhandled {
6767
if fn, ok := bh.hook.(BindClickedHook[T]); ok {
68-
err = fn(elem, param.(string))
68+
err = fn(bh, elem, param.(string))
6969
}
7070
}
7171
}

0 commit comments

Comments
 (0)