diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-06 09:42:12 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-06 09:42:12 +0000 |
commit | eb6571a860ff8c37c3583145be57287e8af97533 (patch) | |
tree | cd0a8b46f0b92608ec8997ca542d99029f28b1c5 /ext/tk/lib/tk/event.rb | |
parent | d9034d23ce8dcb88f310a9e33b79379123c1f7fd (diff) |
* ext/tk/lib : improve framework of developping Tcl/Tk extension wrappers
* BWidget extension support on Ruby/Tk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk/event.rb')
-rw-r--r-- | ext/tk/lib/tk/event.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb index 4c6c0844b2..19fd9dbf00 100644 --- a/ext/tk/lib/tk/event.rb +++ b/ext/tk/lib/tk/event.rb @@ -117,9 +117,21 @@ module TkEvent # that is generated by _get_subst_key() or _get_all_subst_keys(). # _setup_subst_table(KEY_TBL, PROC_TBL); + + + # If you need support extra arguments given by Tcl/Tk, + # please override _get_extra_args_tbl + # + #def self._get_extra_args_tbl + # # return an array of convert procs + # [] + #end + end def install_bind_for_event_class(klass, cmd, *args) + extra_args_tbl = klass._get_extra_args_tbl + if args.compact.size > 0 args = args.join(' ') keys = klass._get_subst_key(args) @@ -130,7 +142,9 @@ module TkEvent id = install_cmd(cmd) else id = install_cmd(proc{|*arg| - TkUtil.eval_cmd(cmd, *klass.scan_args(keys, arg)) + ex_args = [] + extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} + TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg)))) }) end id + ' ' + args @@ -143,7 +157,10 @@ module TkEvent id = install_cmd(cmd) else id = install_cmd(proc{|*arg| - TkUtil.eval_cmd(cmd, klass.new(*klass.scan_args(keys, arg))) + ex_args = [] + extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} + TkUtil.eval_cmd(cmd, + *(ex_args << klass.new(*klass.scan_args(keys, arg)))) }) end id + ' ' + args @@ -151,7 +168,7 @@ module TkEvent end def install_bind(cmd, *args) - install_bind_for_event_class(Event, cmd, *args) + install_bind_for_event_class(TkEvent::Event, cmd, *args) end end |