# Cairo translate with mouse dragging

**URL:** <https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086>\
**Category:** Ruby-Gnome 2\
**Created:** [April 28, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086 "2008-04-28T20:28:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KONTRAS\_Gergely](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@KONTRAS\_Gergely](https://www.ruby-forum.com/u/KONTRAS_Gergely)\
**Post date:** [April 28, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086/1 "2008-04-28T20:28:56Z")

</div>

[http://pastebin.com/d1a425431](http://pastebin.com/d1a425431)

Hi all!

I would like to have a DrawingArea + Cairo, which is zoomable and  
pannable.

The Zoomable aspect is done by me, but I do not know how to implement  
the pannable.

Which Gdk::Event should I enable to handle panning with left or middle  
button drag?  
Which signal to connect to?

thanks  
Gergo

–  
±[Gergely K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ]------------------+  
| |  
| Mobile:(+36 20)356 9656 |  
| |  
± “Olyan lángész vagyok, hogy poroltóval kellene járnom!” -+

---

<div class="post-metadata">

**Author:** ![KONTRAS\_Gergely](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@KONTRAS\_Gergely](https://www.ruby-forum.com/u/KONTRAS_Gergely)\
**Post date:** [April 28, 2008, 10:43pm UTC](https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086/2 "2008-04-28T22:43:46Z")

</div>

Am Montag, den 28.04.2008, 18:32 +0200 schrieb KONTRA, Gergely:

> button drag?  
> Which signal to connect to?

Hi,

check for Gdk::Event::BUTTON\_PRESS for start of dragging, observe the  
dragging with Gdk::Event::MOTION\_NOTIFY and end it with  
Gdk::Event::BUTTON\_RELEASE . To get the information, wich button is  
pressed use event.button from the signal handler.

Cheers, detlef

---

<div class="post-metadata">

**Author:** ![KONTRAS\_Gergely](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@KONTRAS\_Gergely](https://www.ruby-forum.com/u/KONTRAS_Gergely)\
**Post date:** [April 29, 2008, 10:19am UTC](https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086/3 "2008-04-29T10:19:11Z")

</div>

I thought BUTTON1\_MOTION\_MASK has to do something with dragging with  
button1, but maybe I was wrong…

On Mon, Apr 28, 2008 at 9:34 PM, Detlef R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > the pannable.  
> > Gdk::Event::BUTTON\_RELEASE . To get the information, wich button is  
> > This [SF.net](http://SF.net) email is sponsored by the 2008 JavaOne(SM) Conference  
> > Don’t miss this year’s exciting event. There’s still time to save $100.  
> > Use priority code J8TL2D2.  
> > [http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone](http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone)
> 
> * * *
> 
> ruby-gnome2-devel-en mailing list  
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

–  
±[Gergely K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ]------------------+  
| |  
| Mobile:(+36 20)356 9656 |  
| |  
± “Olyan lángész vagyok, hogy poroltóval kellene járnom!” -+

---

<div class="post-metadata">

**Author:** ![KONTRAS\_Gergely](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@KONTRAS\_Gergely](https://www.ruby-forum.com/u/KONTRAS_Gergely)\
**Post date:** [April 29, 2008, 10:23am UTC](https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086/4 "2008-04-29T10:23:19Z")

</div>

And what about the drag-motion signal? What should I type to  
add\_events to be able to catch that? Or is that for something else?

On Tue, Apr 29, 2008 at 10:18 AM, KONTRA, Gergely [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > thanks  
> > > ruby-gnome2-devel-en mailing list  
> > > | |  
> > > | Mobile:(+36 20)356 9656 |  
> > > | |  
> > > ± “Olyan lángész vagyok, hogy poroltóval kellene járnom!” -+

–  
±[Gergely K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ]------------------+  
| |  
| Mobile:(+36 20)356 9656 |  
| |  
± “Olyan lángész vagyok, hogy poroltóval kellene járnom!” -+

---

<div class="post-metadata">

**Author:** ![KONTRAS\_Gergely](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9e8a1a/32.png) [@KONTRAS\_Gergely](https://www.ruby-forum.com/u/KONTRAS_Gergely)\
**Post date:** [April 29, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/cairo-translate-with-mouse-dragging/136086/5 "2008-04-29T16:27:18Z")

</div>

Hi!

Thanks for the reply, I have completed the example, and refactored the  
reusable parts.  
(DragZoomDrawingArea should be reusable class)

Here is it:

> **[Gergely Kontra - Pastebin.com](https://pastebin.com/f63c6aaa9)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

Zooming respect current mouse position

On Mon, Apr 28, 2008 at 9:34 PM, Detlef R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > the pannable.  
> > Gdk::Event::BUTTON\_RELEASE . To get the information, wich button is  
> > This [SF.net](http://SF.net) email is sponsored by the 2008 JavaOne(SM) Conference  
> > Don’t miss this year’s exciting event. There’s still time to save $100.  
> > Use priority code J8TL2D2.  
> > [http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone](http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone)
> 
> * * *
> 
> ruby-gnome2-devel-en mailing list  
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

–  
±[Gergely K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ]------------------+  
| |  
| Mobile:(+36 20)356 9656 |  
| |  
± “Olyan lángész vagyok, hogy poroltóval kellene járnom!” -+
