Double-click in Gtk::Entry

The following Gtk::Entry never gets Gdk::Event::BUTTON2_PRESS:

class A < Gtk::Entry
def initialize
super
add_events Gdk::Event::BUTTON_PRESS_MASK
signal_connect ‘button_press_event’ do |widget, event|
select_range 0, -1 if event.event_type ==
Gdk::Event::BUTTON2_PRESS and event.button == 1
false
end
end
end

What am I doing wrong?

Le 20 mars 2012 14:54, Nikolai W. [email protected] a crit :

end


ruby-gnome2-devel-en mailing list
[email protected]
ruby-gnome2-devel-en List Signup and Options

Hi

I tried

signal_connect ‘button_press_event’ do |widget, event|
p “ok” if Gdk::Event::Type::BUTTON2_PRESS==event.event_type
false
end

and it works.

On Tue, Mar 20, 2012 at 14:54, Nikolai W. [email protected] wrote:

end
end
end

What am I doing wrong?

Here’s a complete example:

require ‘gtk2’

e = Gtk::Entry.new
e.signal_connect ‘button_press_event’ do |widget, event|
p event.event_type
e.select_range 0, -1 if
event.event_type == Gdk::Event::BUTTON2_PRESS and
event.button == 1
end
d = Gtk::Dialog.new
d.vbox.add e
d.show_all
Gtk.main

All I seem to get is two instances of #<Gdk::Event::Type
button-press>. This is on Windows, by the way, but that shouldn’t be
relevant.

On Wed, Mar 21, 2012 at 11:08, [email protected] wrote:

Your example works for me as soon as I change “select_range” to
“select_region”. When I double click, I see:

#<Gdk::Event::Type button-press>
#<Gdk::Event::Type button-press>
#<Gdk::Event::Type 2button-press>

I guess there’s a bug in Gdk for Windows in the version I’m running,
then.

That’s a bummer.

Your example works for me as soon as I change “select_range” to
“select_region”. When I double click, I see:

#<Gdk::Event::Type button-press>
#<Gdk::Event::Type button-press>
#<Gdk::Event::Type 2button-press>

From: Nikolai W. [email protected]
To: Ruby-GNOME2 Developers
[email protected],
Date: 03/21/2012 05:41 AM
Subject: Re: [ruby-gnome2-devel-en] Double-click in Gtk::Entry

On Tue, Mar 20, 2012 at 14:54, Nikolai W. [email protected] wrote:

end
end
end

What am I doing wrong?

Here’s a complete example:

require ‘gtk2’

e = Gtk::Entry.new
e.signal_connect ‘button_press_event’ do |widget, event|
p event.event_type
e.select_range 0, -1 if
event.event_type == Gdk::Event::BUTTON2_PRESS and
event.button == 1
end
d = Gtk::Dialog.new
d.vbox.add e
d.show_all
Gtk.main

All I seem to get is two instances of #<Gdk::Event::Type
button-press>. This is on Windows, by the way, but that shouldn’t be
relevant.