Gtk.Scale value-changed signal vs drag-end?

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

Question in brief: Does the Gtk.Scale widget have a drag-end signal as opposed to value-changed?

I'm using a gtk scale widget (a slider) and according to the docs I should use the value-changed signal to detect when the user changes the slider.

Now the user grabs the slider and drags it to their desired value. When they have finished choosing their desired value (i.e. finished dragging), I want to do some stuff.

However, the value-changed signal gets emitted each time the value changes including while the user is still in the process of dragging the slider to their desired value, so I get one of these signals for every value in between the start value and the end value.

This introduces significant lag into my program and all uncessarily.

So - is there a way I can listen for a signal that fires when the user has finished changing the value on the slider, as opposed to a signal that fires every time the value changes?

At the moment I am throttling the calls by waiting some small set amount of time before executing my code, responding only to the last value-changed signal I receive in that period. This works OK, but I was just wondering if there is a more appropriate signal I should be listening to.

回答1:

Check gtk_range_set_update_policy() function. You want to set policy to GTK_UPDATE_DISCONTINUOUS.



回答2:

You can use change-value signal instead. The second argument is Gtk.ScrollType. Comparing this with Gtk.ScrollType.JUMP should produce the desired result.



回答3:

There's no public API to do that. I think your approach is fine.



回答4:

In GTK+3 (at least), Scale inherits from Widget, which emits the button-release-event signal.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!