From 581ca6097ea061e7b348ed098ca56f809aba4499 Mon Sep 17 00:00:00 2001 From: nagai Date: Mon, 4 Oct 2004 03:56:00 +0000 Subject: * ext/tk/lib/tk/image.rb: bug fix * ext/tk/lib/tk/optiondb.rb: support definition of command resources on widgets git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/MANIFEST | 2 ++ ext/tk/lib/tk/image.rb | 2 +- ext/tk/lib/tk/optiondb.rb | 58 +++++++++++++++++++++++++++++++++++++++++++ ext/tk/sample/cmd_res_test.rb | 17 +++++++++++++ ext/tk/sample/cmd_resource | 5 ++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 ext/tk/sample/cmd_res_test.rb create mode 100644 ext/tk/sample/cmd_resource (limited to 'ext/tk') diff --git a/ext/tk/MANIFEST b/ext/tk/MANIFEST index 64d260a672..28a9e23ee2 100644 --- a/ext/tk/MANIFEST +++ b/ext/tk/MANIFEST @@ -263,6 +263,8 @@ sample/binding_sample.rb sample/bindtag_sample.rb sample/binstr_usage.rb sample/btn_with_frame.rb +sample/cmd_res_test.rb +sample/cmd_resource sample/encstr_usage.rb sample/iso2022-kr.txt sample/menubar1.rb diff --git a/ext/tk/lib/tk/image.rb b/ext/tk/lib/tk/image.rb index e7da1ba207..7868ed0c8f 100644 --- a/ext/tk/lib/tk/image.rb +++ b/ext/tk/lib/tk/image.rb @@ -107,7 +107,7 @@ class TkPhotoImage'BtnFrame').pack +b = TkButton.new(:parent=>f, :widgetname=>'hello').pack +cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 3) +cmd2 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, cmd1) +cmd3 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, b) +cmd4 = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3){ + def self.__check_proc_string__(str) + "{|arg| print [arg, $SAFE].inspect, ': '; Proc.new#{str}.call(arg)}" + end +} +cmd1.show_msg('cmd1') +cmd2.show_msg('cmd2') +cmd3.show_msg('cmd3') +cmd4.show_msg('cmd4') diff --git a/ext/tk/sample/cmd_resource b/ext/tk/sample/cmd_resource new file mode 100644 index 0000000000..9cc4915546 --- /dev/null +++ b/ext/tk/sample/cmd_resource @@ -0,0 +1,5 @@ +*BtnFrame.hello.text: HELLO +*BtnFrame.hello.command: ruby {puts "Hello World!!"} +*BTN_CMD.show_msg: {|arg| print "Hello, #{arg}!!\n"} +*hello.show_msg: {|arg| print "Hello, Hello, #{arg}!!\n"} +*hello.ZZZ.show_msg: {|arg| print "Hello, Hello, ZZZ:#{arg}!!\n"} -- cgit v1.2.3