fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design

Home Page:https://fyne.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clicking on the slider to select it may move the slider

chmike opened this issue · comments

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

When we simply want to select the slider to move it with the arrow keys for a precise adjustment, the slider should not move.

It currently moves when the slider is selected unless we manage to click right in the middle.

The slider show move, only if the mouse is moved beyond an number of pixel. This is equivalent to make the slider a bit sticky at the start. The purpose is to avoid an accidental move when selecting the slider.

How to reproduce

Use the example code below and, on a desktop, select the slider by clicking slightly on its right or left side. This will move the slider.

Selecting the slider should not move the slider.

Screenshots

No response

Example code

The following code can be used to see the change in position when simply selecting the slider.

package main

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/widget"
)

func main() {

	a := app.New()
	w := a.NewWindow("Hello World")

	slider := widget.NewSlider(-1, 0)
	slider.Step = 0.001
	slider.OnChanged = func(x float64) {
		fmt.Println("slider value:", x)
	}
	w.SetContent(slider)
	w.Resize(fyne.NewSize(200, 200))
	w.ShowAndRun()
}

Fyne version

2.4.4

Go compiler version

go version go1.21.4 linux/amd64

Operating system and version

Ubuntu 22.04.4 LTS (jammy)

Additional Information

No response

This isn't a bug, it's intended behavior. The click-to-move slider behavior didn't exist originally but it was added, because "why doesn't the slider move when you tap it" was a much more common request. If you want to focus the slider for keyboard operation, using the Tab key to cycle through the focusable elements is recommended.

But if you just want to disable this behavior, you can override the Tapped implementation with an extended slider so that it just focuses the slider but does not change its value.

Thank you very much. It's OK then.