File: pointer_grab.rb

package info (click to toggle)
ruby-gnome2 2.2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,360 kB
  • ctags: 14,222
  • sloc: ansic: 85,875; ruby: 38,232; sh: 80; xml: 41; makefile: 22
file content (34 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
=begin
  pointer_grab.rb - Gdk::Window#pointer_grab/ungrab sample script.

  Copyright (C) 2001-2006 Masao Mutoh<mutoh@highway.ne.jp>
  This program is licenced under the same licence as Ruby-GNOME.

  $Date: 2006/06/17 13:18:12 $
  $Id: pointer_grab.rb,v 1.5 2006/06/17 13:18:12 mutoh Exp $
=end

require 'gtk3'

window = Gtk::Window.new("Pointer grab/ungrab sample")

cursor = Gdk::Cursor.new(Gdk::Cursor::WATCH)
button1 = Gtk::Button.new("Grab Window!")
button2 = Gtk::Button.new("Ungrab Window!")

button1.signal_connect('clicked') do 
  Gdk.pointer_grab(window.window, true, Gdk::Event::BUTTON_PRESS_MASK, 
			     window.window, cursor, Gdk::Event::CURRENT_TIME)
  p Gdk.pointer_is_grabbed?
end

button2.signal_connect('clicked') do
  Gdk.pointer_ungrab(Gdk::Event::CURRENT_TIME)
  p Gdk.pointer_is_grabbed?
end

window.add(Gtk::VBox.new.add(button1).add(button2))
window.set_default_size(200,100).show_all
window.signal_connect("destroy"){Gtk.main_quit}

Gtk.main