[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Feather slider problem



Phil Martin wrote:

The problem with the feather slider is that after sending wxEVT_SCROLL_THUMBRELEASE wxWidgets sends two more wxEVT_COMMAND_SLIDER_UPDATED events.

Camelot then thinks another drag is starting and sets everything up and it gets left in an unhappy state.

I'm investigating ways to workaround this.

Phil

I have had to patch wxWidgets to fix this. The patch only applies to GTK2.

I have created a diff file (attached) but I'm not sure what the procedure is from here on in (I'm new to this).

Phil


--- slider.cpp	2006-03-21 23:42:17.000000000 +0000
+++ slider new.cpp	2006-04-05 15:50:17.000000000 +0100
@@ -59,19 +59,36 @@
     const int orient = win->HasFlag(wxSL_VERTICAL) ? wxVERTICAL
                                                    : wxHORIZONTAL;
 
     const int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
 
+    // if we have a thumb release event, send this specific event alone
+	// without the extra wxEVT_SCROLL_CHANGED or wxEVT_COMMAND_SLIDER_UPDATED messages
+    if ( evtType == wxEVT_SCROLL_THUMBRELEASE )
+    {
+        wxScrollEvent event( evtType, win->GetId(), value, orient );
+        event.SetEventObject( win );
+        win->GetEventHandler()->ProcessEvent( event );
+		return;
+    }
+
     // if we have any "special" event (i.e. the value changed by a line or a
     // page), send this specific event first
     if ( evtType != wxEVT_NULL )
     {
         wxScrollEvent event( evtType, win->GetId(), value, orient );
         event.SetEventObject( win );
         win->GetEventHandler()->ProcessEvent( event );
     }
 
+#ifdef __WXGTK20__
+	// If we can rely on the IsScrolling flag then avoid sending drag events
+	// when we know a drag is not running...
+	if (win!=NULL && !win->m_isScrolling)
+		return;
+#endif
+
     // but, in any case, except if we're dragging the slider (and so the change
     // is not definitive), send a generic "changed" event
     if ( evtType != wxEVT_SCROLL_THUMBTRACK )
     {
         wxScrollEvent event(wxEVT_SCROLL_CHANGED, win->GetId(), value, orient);