diff options
Diffstat (limited to 'ext/tk/lib/tk/canvas.rb')
-rw-r--r-- | ext/tk/lib/tk/canvas.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index 7d3d71675c..af404213e7 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.rb @@ -85,11 +85,16 @@ class Tk::Canvas<TkWindow # create a canvas item without creating a TkcItem object def create(type, *args) - type = TkcItem.type2class(type.to_s) unless type.kind_of?(TkcItem) + if type.kind_of?(Class) && type < TkcItem + # do nothing + elsif TkcItem.type2class(type.to_s) + type = TkcItem.type2class(type.to_s) + else + fail ArgumentError, "type must a subclass of TkcItem class, or a string in CItemTypeToClass" + end type.create(self, *args) end - def addtag(tag, mode, *args) mode = mode.to_s if args[0] && mode =~ /^(above|below|with(tag)?)$/ |