Forum: Ruby-Gnome 2 Automate a button click

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0158871402c1ecfa57952e8a379cfd10?d=identicon&s=25 Daniel Lucraft (lucraft)
on 2009-04-23 21: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 = Gdk::EventButton.new(Gdk::Event::BUTTON_PRESS)
  when :release
    event_button = Gdk::EventButton.new(Gdk::Event::BUTTON_RELEASE)
  end
  event_button.x = x
  event_button.y = y
  event_button.button = button
  event_button.time = Gdk::Event::CURRENT_TIME
  event_button.window = window
  event_button
end

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

left_click_on(gtk_button)

# --end

thanks
Dan

____________________________________
Daniel Benjamin Lucraft

www.daniellucraft.com/blog
twitter.com/danlucraft
4913bcb685792f601ae9813b4713abb9?d=identicon&s=25 Detlef Reichl (Guest)
on 2009-04-24 00:05
(Received via mailing list)
am Thu, 23 Apr 2009 20:17:04 +0100, tat Daniel Lucraft
<dan@fluentradical.com> der Welt kund:

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

Hi,

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
--
http://det.cable.nu
0158871402c1ecfa57952e8a379cfd10?d=identicon&s=25 Daniel Lucraft (lucraft)
on 2009-04-24 10: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?

Dan
____________________________________
Daniel Benjamin Lucraft

www.daniellucraft.com/blog
twitter.com/danlucraft



2009/4/23 Detlef Reichl <detlef.reichl@gmx.org>:
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2009-04-24 11:26
Cant you use this:

.signal_emit(:clicked)

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