Blob Blame History Raw
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Chapter 3. Events</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="The Clutter Cookbook"><link rel="up" href="index.html" title="The Clutter Cookbook"><link rel="prev" href="actors-non-rectangular.html" title="6. Creating an actor with a non-rectangular shape"><link rel="next" href="events-handling-key-events.html" title="2. Handling key events"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 3. Events</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="actors-non-rectangular.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="events-handling-key-events.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="events"></a>Chapter 3. Events</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="events.html#events-introduction">1. Introduction</a></span></dt><dt><span class="section"><a href="events-handling-key-events.html">2. Handling key events</a></span></dt><dd><dl><dt><span class="section"><a href="events-handling-key-events.html#idm140200513092848">2.1. Problem</a></span></dt><dt><span class="section"><a href="events-handling-key-events.html#idm140200513091536">2.2. Solutions</a></span></dt><dt><span class="section"><a href="events-handling-key-events.html#events-handling-key-events-discussion">2.3. Discussion</a></span></dt></dl></dd><dt><span class="section"><a href="events-mouse-scroll.html">3. Detecting mouse scrolling on an actor</a></span></dt><dd><dl><dt><span class="section"><a href="events-mouse-scroll.html#idm140200508414352">3.1. Problem</a></span></dt><dt><span class="section"><a href="events-mouse-scroll.html#idm140200508412880">3.2. Solution</a></span></dt><dt><span class="section"><a href="events-mouse-scroll.html#idm140200508405008">3.3. Discussion</a></span></dt><dt><span class="section"><a href="events-mouse-scroll.html#idm140200508364384">3.4. Full example</a></span></dt></dl></dd><dt><span class="section"><a href="events-pointer-motion.html">4. Detecting pointer movements on an actor</a></span></dt><dd><dl><dt><span class="section"><a href="events-pointer-motion.html#events-pointer-motion-problem">4.1. Problem</a></span></dt><dt><span class="section"><a href="events-pointer-motion.html#events-pointer-motion-solution">4.2. Solution</a></span></dt><dt><span class="section"><a href="events-pointer-motion.html#events-pointer-motion-discussion">4.3. Discussion</a></span></dt><dt><span class="section"><a href="events-pointer-motion.html#idm140200508304032">4.4. Full examples</a></span></dt></dl></dd><dt><span class="section"><a href="events-buttons.html">5. Making an actor respond to button events</a></span></dt><dd><dl><dt><span class="section"><a href="events-buttons.html#idm140200508275760">5.1. Problem</a></span></dt><dt><span class="section"><a href="events-buttons.html#idm140200508270480">5.2. Solution</a></span></dt><dt><span class="section"><a href="events-buttons.html#idm140200508253488">5.3. Discussion</a></span></dt><dt><span class="section"><a href="events-buttons.html#idm140200508209072">5.4. Full examples</a></span></dt></dl></dd></dl></div><div class="epigraph"><p>Crossing into established events is strictly forbidden. Except for
    cheap tricks.</p><div class="attribution"><span>—<span class="attribution">The Tenth Doctor (David Tennant)</span></span></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="events-introduction"></a>1. Introduction</h2></div></div></div><p>Once you have set up a scene on the stage, in order to respond
    to user interaction you will have to handle events coming from the
    underlying platform.</p><p>Events are relayed to actors by Clutter in form of
    <span class="emphasis"><em>signals</em></span>; signals are a facility provided by the
    GObject framework to call functions depending on a unique name. A signal
    can be thought as a message that an object instance broadcasts to various
    listener functions.</p><p>There are various events that Clutter will handle: mostly, they
    deal with input devices, like a mouse pointer or a keyboard; but they can
    also come from the windowing system, like the
    <span class="emphasis"><em>delete-event</em></span> signal that is emitted when the user
    closes the window of the stage.</p><p>Each event has a particular <span class="emphasis"><em>source</em></span>, that is
    the actor that received the event. The event handling sequence is divided
    in two phases:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>the <span class="emphasis"><em>capture</em></span> phase, which consists
      in an emission of the <span class="emphasis"><em>captured-event</em></span> signal
      starting from the stage to, following the parent-child relationship,
      the source of the event;</p></li><li class="listitem"><p>the <span class="emphasis"><em>bubble</em></span> phase, which consists
      in an emission of the <span class="emphasis"><em>event</em></span> signal starting from
      the source of the event to, following the parent-child
      relationship, the stage.</p></li></ol></div><p>At any point during the event emission sequence a handler of either
    the captured-event or the event signals can stop it, by returning a boolean
    value of <span class="emphasis"><em>true</em></span>, which means that the event has been
    handled. If an event hasn't  been handled, a boolean value of
    <span class="emphasis"><em>false</em></span> should be returned instead.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Clutter provides two useful macros to avoid remembering which
    boolean value should be used in an event signal handler:
    CLUTTER_EVENT_PROPAGATE, equivalent to FALSE; and CLUTTER_EVENT_STOP,
    equivalent to TRUE.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="actors-non-rectangular.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="events-handling-key-events.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6. Creating an actor with a non-rectangular shape </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 2. Handling key events</td></tr></table></div></body></html>