Skip to content

Update spin value periodically if left mouse pressed is been holding - #137

Closed
Kvaz1r wants to merge 2 commits into
texus:0.9-devfrom
Kvaz1r:Spinbuttonholding
Closed

Kvaz1r wants to merge 2 commits into
texus:0.9-devfrom
Kvaz1r:Spinbuttonholding

Conversation

@Kvaz1r

@Kvaz1r Kvaz1r commented Jul 18, 2020

Copy link
Copy Markdown
Contributor

I'm not sure that Timer::scheduleCallback is the right choice here, but idea is simple - move changing value from mouse release handler to mouse pressed handler and to call changer periodically while some conditions (mouse still pressed, mouse still hover on widget and correct spin button and there wasn't any new clicks) are still being true.

@texus

texus commented Jul 19, 2020

Copy link
Copy Markdown
Owner

I like the idea of using Timer::scheduleCallback.
Although it is unlikely to happen, I fear that it could cause issues if the widget is destroyed between scheduling the callback and receiving it. Instead of capturing this in the labmda, it would probably be better to capture something like spinButton=shared_from_this() and add spinButton-> in front of variables and functions inside the lambda. That way the widget can't be destroyed until after the scheduled lambda has been executed.

@Kvaz1r

Kvaz1r commented Jul 19, 2020

Copy link
Copy Markdown
Contributor Author

Fixed

@texus

texus commented Jul 19, 2020

Copy link
Copy Markdown
Owner

Manually merged as 8e8db09

@texus texus closed this Jul 19, 2020
@Kvaz1r
Kvaz1r deleted the Spinbuttonholding branch July 19, 2020 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants