Ruby-GNOME2: Getting double clicks?

I would appreciate any help in getting double mouse clicks to work in ruby
Gtk2.

I have the following:

@tree.signal_connect( “button_press_event”, Gdk::Event::BUTTON2_PRESS ){

widget,event,data| double_click_cb( widget, event, data ) }

is this right?

what goes in:
def double_click_cb ( widget, event, data )

end

Additionally what are the advantages/disadvantages of implementing
callbacks as Proc rather than methods?

Thanks
A new ruby convert

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----

Hi,

I would appreciate any help in getting double mouse clicks to work in ruby
Gtk2.

I have the following:

@tree.signal_connect( “button_press_event”, Gdk::Event::BUTTON2_PRESS ){

widget,event,data| double_click_cb( widget, event, data ) }

is this right?

If you want to use double-click under Gtk::TreeView,
“row-activated” signal may be better.

@tree.signal_connect(“row-activated”) do … end

If you want to use it under Gtk::Button. You can write it as follows:

button.signal_connect(“button_press_event”) do |widget, event|
if event.event_type == Gdk::Event::BUTTON2_PRESS
p “double click”
elsif event.event_type == Gdk::Event::BUTTON3_PRESS
p “triple click”
end
end

Other widget which doesn’t get “button_press_event” may need to write
as follows:

window.add_events(Gdk::Event::BUTTON_PRESS_MASK)
window.signal_connect(“button_press_event”) do |widget, event|
if event.event_type == Gdk::Event::BUTTON2_PRESS
p “double click”
elsif event.event_type == Gdk::Event::BUTTON3_PRESS
p “triple click”
end
end

what goes in:
def double_click_cb ( widget, event, data )

end

‘data’ is not supported in Ruby-GNOME2.

Additionally what are the advantages/disadvantages of implementing
callbacks as Proc rather than methods?

Hmm, it’s a dificult question…

IMO,
callbacks as Proc: Smaller and not reuse it.
methods: Larger or reuse it.
Usually I delegate processing to other object’s
methods(like as MVC pattern).

In the both pattern, I don’t like codes as follows.

···

On Thu, 27 Feb 2003 04:16:27 +0900 “PS” ps@inet-services.co.uk wrote:

window.signal_connect(“button_press_event”) do |widget, event|
if event.event_type == Gdk::Event::BUTTON2_PRESS
double_click_cb(widget, event)
end
end

def double_click_cb(widget, event)
end

double_click_cb:

  • the method name is not good because it means to use it
    callback only.
  • parameters are depend on callback.

So I think this method is difficult to reuse.

It’s better to pass the parameter which the method actually requires.

window.signal_connect(“button_press_event”) do |widget, event|
if event.event_type == Gdk::Event::BUTTON2_PRESS
do_something(“something value”)
end
end

def do_something(arg)
end



.:% Masao Mutohmutoh@highway.ne.jp

Thank you for your prompt and comprehensive reply, you’ve saved me from
another few days of head scratching.

···

On Thu, 27 Feb 2003 23:20:18 +0900, Masao Mutoh wrote:

Hi,

On Thu, 27 Feb 2003 04:16:27 +0900 > “PS” ps@inet-services.co.uk wrote:

I would appreciate any help in getting double mouse clicks to work in ruby
Gtk2.

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----