Gtk.jl icon indicating copy to clipboard operation
Gtk.jl copied to clipboard

GtkScale ignores range step size

Open yakir12 opened this issue 3 years ago • 3 comments

The scale/slider in the following MWE ignores the size of the step of the range:

using Gtk
win = GtkWindow("My First Gtk.jl Program", 400, 200)
b = GtkScale(false, 1:2:11)
push!(win,b)
showall(win)

It behaves identically to

...
b = GtkScale(false, 1:11)
...

yakir12 avatar Aug 08 '22 19:08 yakir12

From: https://docs.gtk.org/gtk3/ctor.Scale.new_with_range.html

"step must be nonzero; it’s the distance the slider moves when using the arrow keys to adjust the scale value."

I would have expected something different as well but it works like it is documented.

tknopp avatar Aug 08 '22 20:08 tknopp

Fair enough but horrible. The values the slider outputs should/must be members of the range/set it got as input, not to mention that they aught to match what you get if you use the mouse versus the keyboard (albeit can be different if you use the arrows with a modifier key). I can work around this, but it caught me by surprise. Maybe we should add a note box to the docs and warn users about it.

yakir12 avatar Aug 08 '22 21:08 yakir12

I think the actual increment can be set when first creating a GtkAdjustment and use that to create the GtkScale. I usually do this within Glade.

tknopp avatar Aug 08 '22 21:08 tknopp