Re: GtkText and GtkVScrollbar
| From: | James Cameron | Date: | Mon, 12 Aug 2002 23:08:55 +0000 |
| Subject: | Re: GtkText and GtkVScrollbar | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-2316@lists.php.net to get a copy of this message | ||
There may be another way to do this, or it might be in GTK+ 2.0
already, but here is how I would do it today with GTK+ 1.x ...
On Mon, Aug 12, 2002 at 11:53:03PM +0200, Anders K. Madsen wrote:
> The scrollbar works fine together with the text-widget, but
> I want it to react on my scroll-button on the mouse as well.
> As of now it only reacts to pointing at the scrollbar and drag.
Your problem reduces to being able to move the scroll bar under control
of your program, as a response to buttons 4 & 5 detected anywhere in the
application window.
a) adjusting a scroll bar within a program is done by calling the
functions for the GtkAdjustment class passing the scroll bar widget as
the adjustment pointer. See the reference pages for GtkAdjustment,
GtkRange, and GtkVScrollBar. The existing adjustment value is read,
an offset is added or subtracted, and set_value is called.
References:
http://gtk.php.net/manual/en/gtk.gtkvscrollbar.php
http://gtk.php.net/manual/en/gtk.gtkrange.php
http://gtk.php.net/manual/en/gtk.gtkadjustment.php
b) capturing the mouse buttons 4 & 5 is done by placing a GtkEventBox
as the ancestor of everything else in the window except the toplevel
widget. Then ask the GtkEventBox to call your handler on a
button-press-event (a method in the GtkWidget ancestor class of
GtkEventBox), and when this happens check the event structure for a
type of GDK_BUTTON_PRESS, and a button value of 4 for scrolling up,
or 5 for scrolling down.
References:
http://gtk.php.net/manual/en/gtk.gtkeventbox.php
http://gtk.php.net/manual/en/gtk.gtkwidget.php
http://gtk.php.net/manual/en/gtk.gtkwidget.signal.button-press-event.php
http://gtk.php.net/manual/en/gdk.enum.gdkeventtype.php
--
James Cameron mailto:quozl@us.netrek.org http://quozl.netrek.org/