Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Back  Login

tut-clutter-signal Diff - Ruby-GNOME2 Project Website

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

= Ruby/Clutter Tutorial: Signal

== Overview

  require "clutter"
  stage = Clutter::Stage.new

  stage.signal_connect("destroy") do
    Clutter.main_quit
  end

  stage.signal_connect("button-press-event") do |actor, event|
    puts actor.class
    puts event.class
  end

  stage.signal_connect("key-press-event") do |actor, event|
    puts actor.class
    puts event.class
  end

  stage.show
  Clutter.main

== Explanation

=== signal_connect

  stage.signal_connect("signal-name") do
    ...
  end

When "signal-name" signal occurred, the process come to in the block.

=== "destroy"

  stage.signal_connect("destroy") do
    Clutter.main_quit
  end

"destroy" signal occurs when such as X button pressed.the window destroyed.

=== "button-press-event"


  stage.signal_connect("button-press-event") do |actor, event|
    puts actor.class  #=> Clutter::Stage
    puts event.class  #=> Clutter::ButtonEvent
  end

"button-press-event" signal occurs when such as mouse button pressed.

=== "key-press-event"

  stage.signal_connect("key-press-event") do |actor, event|
    puts actor.class  #=> Clutter::Stage
    puts event.class  #=> Clutter::KeyEvent
  end

"key-press-event" signal occurs when a keyboard key pressed.