Skip to content

Commit

Permalink
don't respond to tapped when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Dec 24, 2023
1 parent 95ef04e commit 20ef8cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions widget/slider.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (s *Slider) Dragged(e *fyne.DragEvent) {
//
// Since: 2.4
func (s *Slider) Tapped(e *fyne.PointEvent) {
if s.disabled {
return
}

driver := fyne.CurrentApp().Driver()
if !s.focused && !driver.Device().IsMobile() {
impl := s.super()
Expand Down
5 changes: 5 additions & 0 deletions widget/slider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ func TestSlider_Disabled(t *testing.T) {
changes++
}

tap := &fyne.PointEvent{}
tap.Position = fyne.NewPos(30, 2)
slider.Tapped(tap)
assert.Equal(t, 0, changes)

drag := &fyne.DragEvent{}
drag.PointEvent.Position = fyne.NewPos(25, 2)
slider.Dragged(drag)
Expand Down

0 comments on commit 20ef8cd

Please sign in to comment.