File: keyboard-grab.rb

package info (click to toggle)
ruby-gnome 4.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,648 kB
  • sloc: ruby: 67,701; ansic: 67,431; xml: 350; sh: 201; cpp: 45; makefile: 42
file content (34 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (5)
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
  keyboard_grab.rb - Gdk::Window#keyboard_grab/ungrab sample script.

  Copyright (C) 2001-2006 Masao Mutoh
  This program is licenced under the same licence as Ruby-GNOME.

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

require "gtk3"

window = Gtk::Window.new("Keyboard Grab/Ungrab sample")

button1 = Gtk::Button.new(:label => "Grab Keyboard!")
button2 = Gtk::Button.new(:label => "Ungrab Keyboard!")

button1.signal_connect("clicked") do
  Gdk.keyboard_grab(window.window, true, Gdk::CURRENT_TIME)
end

button2.signal_connect("clicked") do
  Gdk.keyboard_ungrab(Gdk::CURRENT_TIME)
end

vbox = Gtk::Box.new(:vertical, 0)
vbox.add(button1)
vbox.add(button2)
window.add(vbox)
window.set_default_size(200, 100)
window.show_all
window.signal_connect("destroy") { Gtk.main_quit }

Gtk.main