Forum: Ruby-Gnome 2 Automate a button click

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Daniel L. (Guest)
on 2009-04-23 23:18
(Received via mailing list)
Anyone know what's the matter with this code to automate a button click?

def make_event_button(window, x, y, button, type)
  case type
  when :press
    event_button =
  when :release
    event_button =
  event_button.x = x
  event_button.y = y
  event_button.button = button
  event_button.time = Gdk::Event::CURRENT_TIME
  event_button.window = window

def left_click_on(widget)
  make_event_button(widget.window, 0, 0, 1, :press).put
  make_event_button(widget.window, 0, 0, 1, :release).put


# --end


Daniel Benjamin Lucraft
Detlef R. (Guest)
on 2009-04-24 02:05
(Received via mailing list)
am Thu, 23 Apr 2009 20:17:04 +0100, tat Daniel L.
<removed_email_address@domain.invalid> der Welt kund:

> Anyone know what's the matter with this code to automate a button click?


I don't know, whats wrong with your code, but if you only want to
simulate a button click, why not simply use Gtk::button.activate?

Cheers, detlef
Daniel L. (Guest)
on 2009-04-24 12:05
(Received via mailing list)
Yes, thanks for the tip. I'd prefer to create click events because I
am trying to simluate user input as closely as possible for my
features. Code that simulates a click can be used everywhere, not just
on a button widget.

I tried the activate option anyway (I'll try anything at this point)
but ran into problems. It works on standard buttons, but for some
reason when I call 'activate' on a button in a (non-modal)
FileChooserDialog, the dialog will hang with the button depressed.

I've not been able to figure out why this is. The stranger part is
that it doesn't just hang my application, but in fact hangs the event
loops for ALL applications I have open. I can just about tell Ubuntu
to forcibly close my app, which brings everything else back to life,
thankfully. But my app is dead to the world.

What strange spirits have I angered, please?

Daniel Benjamin Lucraft

2009/4/23 Detlef R. <removed_email_address@domain.invalid>:
Robert H. (Guest)
on 2009-04-24 13:26
Cant you use this:


To trigger a signal?
This topic is locked and can not be replied to.