implement scroll-wheel support for ClickBoxes
This commit is contained in:
parent
f4229968d9
commit
56ba08b7cb
@ -143,6 +143,29 @@ AutoSpin::button_press (GdkEventButton *ev)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
AutoSpin::scroll_event (GdkEventScroll *ev)
|
||||
{
|
||||
stop_spinning (0);
|
||||
|
||||
gfloat increment = step_increment;
|
||||
|
||||
if (ev->state & Keyboard::TertiaryModifier) {
|
||||
increment = page_increment;
|
||||
}
|
||||
|
||||
switch (ev->direction) {
|
||||
case GDK_SCROLL_DOWN:
|
||||
case GDK_SCROLL_LEFT:
|
||||
adjust_value (-increment);
|
||||
break;
|
||||
case GDK_SCROLL_RIGHT:
|
||||
case GDK_SCROLL_UP:
|
||||
adjust_value (increment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AutoSpin::start_spinning (bool decrement, bool page)
|
||||
{
|
||||
|
@ -62,6 +62,13 @@ ClickBox::button_press_handler (GdkEventButton* ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ClickBox::on_scroll_event (GdkEventScroll* ev)
|
||||
{
|
||||
AutoSpin::scroll_event (ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ClickBox::button_release_handler (GdkEventButton* ev)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ class LIBGTKMM2EXT_API AutoSpin
|
||||
gint button_press (GdkEventButton *);
|
||||
gint stop_spinning (GdkEventButton *ignored_but_here_for_clicked);
|
||||
void start_spinning (bool decrementing, bool use_page);
|
||||
gint scroll_event (GdkEventScroll *);
|
||||
|
||||
private:
|
||||
Gtk::Adjustment &adjustment;
|
||||
|
@ -57,6 +57,7 @@ class LIBGTKMM2EXT_API ClickBox : public Gtk::DrawingArea, public AutoSpin
|
||||
void style_changed (const Glib::RefPtr<Gtk::Style> &);
|
||||
bool button_press_handler (GdkEventButton *);
|
||||
bool button_release_handler (GdkEventButton *);
|
||||
bool on_scroll_event (GdkEventScroll*);
|
||||
|
||||
sigc::slot<bool, char *, Gtk::Adjustment &> _printer;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user