Gtk.GestureClick.OnReleased doesn't seem to work #1015
-
I've been currently working on upgrading the Bassoon Jukebox project from GTK3 to GTK4. And I've noticed an issue when replacing the It doesn't work at all. What's odd is that So as a result, I'm currently stuck with this issue: And when I try to replace this code: private bool CheckPlayback()
{
// We need to have an audio file
if (Audio == null)
return false;
if (Audio.IsPlaying)
{
// Turns the MovingPlaybackSlider bool to false when not moving the playback slider
if (!PlaybackSliderClick.IsActive() && !PlaybackSliderDrag.IsActive())
{
MovingPlaybackSlider = false;
}
else
{
MovingPlaybackSlider = true;
var frameClock = PlaybackSlider.GetFrameClock();
var frameTime = frameClock.GetFrameTime();
var frameCounter = frameClock.GetFrameCounter();
var timings = frameClock.GetTimings(frameCounter);
var value = (float)PlaybackSlider.GetValue();
//Audio.Cursor = (float)PlaybackSlider.GetValue();
}
// Adjust the slider if playing (and not scrubbing)
if (!MovingPlaybackSlider && !PlaybackSliderClick.IsActive() && !PlaybackSliderDrag.IsActive())
{
double playbackValue = Map(Audio.Cursor, 0, Audio.Duration.TotalSeconds, PlaybackSlider.Adjustment.Lower, PlaybackSlider.Adjustment.Upper);
PlaybackSlider.Adjustment.Value = playbackValue;
}
return true;
}
// If not, don't do anything
PlayButton.Active = false; // Un-toggle play
return false;
} With this: private bool CheckPlayback()
{
// We need to have an audio file
if (Audio == null)
return false;
if (Audio.IsPlaying)
{
// // Turns the MovingPlaybackSlider bool to false when not moving the playback slider
// if (!PlaybackSliderClick.IsActive() && !PlaybackSliderDrag.IsActive())
// {
// MovingPlaybackSlider = false;
// }
// else
// {
// MovingPlaybackSlider = true;
// var frameClock = PlaybackSlider.GetFrameClock();
// var frameTime = frameClock.GetFrameTime();
// var frameCounter = frameClock.GetFrameCounter();
// var timings = frameClock.GetTimings(frameCounter);
// var value = (float)PlaybackSlider.GetValue();
// //Audio.Cursor = (float)PlaybackSlider.GetValue();
// }
// Adjust the slider if playing (and not scrubbing)
if (!MovingPlaybackSlider)
{
double playbackValue = Map(Audio.Cursor, 0, Audio.Duration.TotalSeconds, PlaybackSlider.Adjustment.Lower, PlaybackSlider.Adjustment.Upper);
PlaybackSlider.Adjustment.Value = playbackValue;
}
return true;
}
// If not, don't do anything
PlayButton.Active = false; // Un-toggle play
return false;
} It will do this instead: Is there anything I'm doing wrong? Is this a bug in Gir.Core? Shouldn't GestureClick.OnRelease event trigger when there's no mouse click occurring? Is there any workarounds? Any help would be greatly appreciated! Also, if anyone needs to test it out for themselves, here's the source code: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
According to the docs it should work. Can you provide a minimal sample application? |
Beta Was this translation helpful? Give feedback.
-
Well, this was interesting. I've managed to fix the issue. It turns out that the issue was that the slider was expecting an So I added these in: PlaybackSliderClick.OnStopped += OnPlaybackSliderMouseUp;
PlaybackSliderClick.OnCancel += OnPlaybackSliderMouseUp;
PlaybackSliderClick.OnReleased += OnPlaybackSliderMouseUp;
PlaybackSliderClick.OnUnpairedRelease += OnPlaybackSliderMouseUp;
PlaybackSliderClick.OnEnd += OnPlaybackSliderMouseUp; And now the slider moves properly and can be adjusted and then will proceed as normal without staying in place.
I mean, I could've just provided the JukeboxGtk4 application on it's own, with it's dependencies intact. Since it is a very small application with just a JukeboxGtk4.csproj and Jukebox.cs files. |
Beta Was this translation helpful? Give feedback.
-
So I couldn't fit it properly using your technique, because "stopped" and "end" arrive early while it's still sliding... In my case I was trying to stop the value being updated in the background by some other mechanism while "sliding". The fix ended up easy once I figured things out. I had to attach the GtkGestureClick to the parent of the slider (I made a GtkBox just aroung the slider for that purpose) and set the GtkGestureClick propagation phase to GTK_PHASE_CAPTURE. In C this is: gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_CAPTURE); |
Beta Was this translation helpful? Give feedback.
So I couldn't fit it properly using your technique, because "stopped" and "end" arrive early while it's still sliding... In my case I was trying to stop the value being updated in the background by some other mechanism while "sliding".
The fix ended up easy once I figured things out. I had to attach the GtkGestureClick to the parent of the slider (I made a GtkBox just aroung the slider for that purpose) and set the GtkGestureClick propagation phase to GTK_PHASE_CAPTURE.
In C this is: gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_CAPTURE);