Subject: [ruby-gnome2-devel-en] Open a context menu with actions in
TextView widget
Date: sab 24 ago 13 02:30:37 +0200
Quoting Marc H. (removed_email_address@domain.invalid):
click?
You can trap signals for your textview: signal ‘button-press-event’ is
emitted when a mouse button is pressed, and ‘button-release-event’ is
emitted when the button is released.
So, if you have something like this:
ebfr=Gtk::TextBuffer::new
ebfr.text=<<-EOF
…
…
…
EOF
et=Gtk::TextView::new(ebfr)
you can add this:
et.signal_connect(‘button-press-event’) do |tv,eb|
…
…
end
et.signal_connect(‘button-release-event’) do |tv,eb|
…
…
end
This specific processing only takes place when the focus of the mouse
is within the textview.
The second parameter you receive when the signal is triggered is an
EventButton instance. Check if eb.button==3, and do whatever you need
to do.
Remember that the return value from the signal_connect block has
meaning. If you return true, it means you have made use of the signal,
and it does not need further processing. If you return false, the
signal is passed downwards.
So, if you want to do something on release of the third mouse button,
first avoid the window manager processing of the click as follows:
et.signal_connect(‘button-press-event’) do |tv,eb|
eb.button==3 ? true : false
end
Then do what you need to do at release
et.signal_connect(‘button-release-event’) do |tv,eb|
return false unless(eb.button==3)
do_what_you_need()
true
end
…
…
def do_what_you_need
dialog=Gtk::Dialog::new(:title=>‘my
title’,:flags=>Gtk::Dialog:
:MODAL)
…
…
end
Hope this helps
Carlo
–
parte,
- K * Carlo E. Prelz - removed_email_address@domain.invalid che bisogno ci
sarebbe
(Chuang-Tzu)