|
From: Sawada T. <saw...@gm...> - 2011-02-19 06:09:10
|
はじめまして
Gtk::Window#add_accel_group
を使って、キーを割り当てようとするとき、Gtk::Entry(またはGtk::TextView)がWindow内にあり、かつキーが押されたときに実行されるべきブロックの中にある種のメソッド(例えばputs)があると、イベントが2重に発生するのですが、これは仕様ですか。1回しか発生させないようにするにはどうしたらいいですか。
具体的には、下のコードで、(a), (b)の行のうちの一方がコメントアウトされたとき、1回Ctrl-Aをおすと、
This does not duplicate the event
と表示されますが、(a), (b)がともにある場合には、1回Ctrl-Aをおすと、
This does not duplicate the event
But this does
This does not duplicate the event
But this does
と表示されてしまいます。
------- コード --------------------------------------------
require 'gtk2'
ag = Gtk::AccelGroup.new.
connect(Gdk::Keyval::GDK_A, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE) {
p 'This does not duplicate the event'
puts "But this does" # (a)
}
Gtk::Window.new.
add(Gtk::Entry.new). # (b)
add_accel_group(ag).show_all
Gtk.main
-----------------------------------------------------------------
|