I am developing a small app with ruby/GTK.
However, there is a problem when trying to change text in an
Entry-box, using the signal "insert-text".
The following small code will show the problem.
This is an example taken from the gtk - user manual.
There it uses the function gtk_block_signal_handler_by_func.
This is not available in the ruby-language bindings, so I use
a global variable.
When a insert text, the text gets there, but the cursor doesn't
Is there a way to make this work, or do I have change to the
--- begin code -----
$block = false
window = Gtk::Window.new
entry = Gtk::Entry.new()
|widget, text, pos|
if not $block
$block = true
$block = false
--- end code ---
On Sun, 28 Jul 2002 17:01:34 +0200 (CEST)
"Kristof Bastiaensen" <kristof@...> wrote:
> This is an example taken from the gtk - user manual.
> There it uses the function gtk_block_signal_handler_by_func.
> This is not available in the ruby-language bindings, so I use
> a global variable.
Hmm, I could not find gtk_block_signal_handler_by_func.
#and I don't know the example what you see.
Is it gtk_signal_connect_by_func?
> When a insert text, the text gets there, but the cursor doesn't
I think this is Ruby/GTK's problem, but I don't have any ideas now.
> Is there a way to make this work, or do I have change to the
I wrote a script same as your code once.
It works fine for ASCII charcter, but it doesn't work with
2-byte character(like Kanji).
entry = Gtk::Entry.new
handler_id = entry.signal_connect_after("insert_text") do |widget, text, pos|
entry.delete_text(pos - 1, pos)
entry.position = pos + text.size
window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
.:% Masao Mutoh<mutoh@...>