~eliasnaur/gio-patches

widget: adding a Pressed() method to button. This is like Clicked() but tells if the button is currently being pressed. v1 PROPOSED

Raffaele Sena
Raffaele Sena: 1
 widget: adding a Pressed() method to button. This is like Clicked() but tells if the button is currently being pressed.

 1 files changed, 5 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/9770/mbox | git am -3
Learn more about email & git

[PATCH] widget: adding a Pressed() method to button. This is like Clicked() but tells if the button is currently being pressed. Export this patch

Raffaele Sena
Signed-off-by: Raffaele Sena <raff367@gmail.com>
---
 widget/button.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/widget/button.go b/widget/button.go
index 24cc8d1..ebb311e 100644
--- a/widget/button.go
+++ b/widget/button.go
@@ -43,6 +43,11 @@ func (b *Button) Clicked(gtx *layout.Context) bool {
	return false
}

func (b *Button) Pressed(gtx *layout.Context) bool {
	b.Clicked(gtx)
	return b.click.State() == gesture.StatePressed
}

func (b *Button) History() []Click {
	return b.history
}
-- 
2.25.0
View this thread in the archives