Override mouse wheel scrolling steps from GTK and make the default 3 steps, also catch mouse wheel when over scrollbars
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57900 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1547,6 +1547,38 @@ gtk_window_motion_notify_callback( GtkWidget * WXUNUSED(widget),
|
||||
// "scroll_event" (mouse wheel event)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static gboolean
|
||||
window_scroll_event_hscrollbar(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
|
||||
{
|
||||
if (gdk_event->direction != GDK_SCROLL_LEFT &&
|
||||
gdk_event->direction != GDK_SCROLL_RIGHT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxMouseEvent event(wxEVT_MOUSEWHEEL);
|
||||
InitMouseEvent(win, event, gdk_event);
|
||||
|
||||
GtkRange *range = win->m_scrollBar[wxWindow::ScrollDir_Horz];
|
||||
if (!range) return FALSE;
|
||||
|
||||
if (range && GTK_WIDGET_VISIBLE (range))
|
||||
{
|
||||
GtkAdjustment *adj = range->adjustment;
|
||||
gdouble delta = adj->step_increment * 3;
|
||||
if (gdk_event->direction == GDK_SCROLL_LEFT)
|
||||
delta = -delta;
|
||||
|
||||
gdouble new_value = CLAMP (adj->value + delta, adj->lower, adj->upper - adj->page_size);
|
||||
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
|
||||
{
|
||||
@@ -1567,7 +1599,27 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
|
||||
else
|
||||
event.m_wheelRotation = -120;
|
||||
|
||||
return win->GTKProcessEvent(event);
|
||||
if (win->GTKProcessEvent(event))
|
||||
return TRUE;
|
||||
|
||||
GtkRange *range = win->m_scrollBar[wxWindow::ScrollDir_Vert];
|
||||
if (!range) return FALSE;
|
||||
|
||||
if (range && GTK_WIDGET_VISIBLE (range))
|
||||
{
|
||||
GtkAdjustment *adj = range->adjustment;
|
||||
gdouble delta = adj->step_increment * 3;
|
||||
if (gdk_event->direction == GDK_SCROLL_UP)
|
||||
delta = -delta;
|
||||
|
||||
gdouble new_value = CLAMP (adj->value + delta, adj->lower, adj->upper - adj->page_size);
|
||||
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2356,8 +2408,16 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
|
||||
G_CALLBACK (gtk_window_button_release_callback), this);
|
||||
g_signal_connect (widget, "motion_notify_event",
|
||||
G_CALLBACK (gtk_window_motion_notify_callback), this);
|
||||
|
||||
g_signal_connect (widget, "scroll_event",
|
||||
G_CALLBACK (window_scroll_event), this);
|
||||
if (m_scrollBar[ScrollDir_Horz])
|
||||
g_signal_connect (m_scrollBar[ScrollDir_Horz], "scroll_event",
|
||||
G_CALLBACK (window_scroll_event_hscrollbar), this);
|
||||
if (m_scrollBar[ScrollDir_Vert])
|
||||
g_signal_connect (m_scrollBar[ScrollDir_Vert], "scroll_event",
|
||||
G_CALLBACK (window_scroll_event), this);
|
||||
|
||||
g_signal_connect (widget, "popup_menu",
|
||||
G_CALLBACK (wxgtk_window_popup_menu_callback), this);
|
||||
g_signal_connect (widget, "enter_notify_event",
|
||||
|
Reference in New Issue
Block a user