Module: Tk::ValidateConfigure
- Included in:
- BLT::DragDrop, BLT::Treeview, Iwidgets::Calendar, Iwidgets::Entryfield, Iwidgets::Hierarchy, Iwidgets::Spinner, TkTable, TkValidation
- Defined in:
- lib/tk/validation.rb
Class Method Summary collapse
Instance Method Summary collapse
- #__conv_vcmd_on_hash_kv(keys) ⇒ Object
- #__get_validate_key2class ⇒ Object
- #__validation_class_list ⇒ Object
- #__validcmd_call(klass, key, *args, &b) ⇒ Object
- #configure(slot, value = TkComm::None) ⇒ Object
Class Method Details
.__def_validcmd(scope, klass, keys = nil) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/tk/validation.rb', line 9 def self.__def_validcmd(scope, klass, keys=nil) keys = klass._config_keys unless keys keys.each{|key| eval("def #{key}(*args, &b) __validcmd_call(#{klass.name}, '#{key}', *args, &b) end", scope) } end |
Instance Method Details
#__conv_vcmd_on_hash_kv(keys) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tk/validation.rb', line 47 def __conv_vcmd_on_hash_kv(keys) key2class = __get_validate_key2class keys = _symbolkey2str(keys) key2class.each{|key, klass| if keys[key].kind_of?(Array) cmd, *args = keys[key] #keys[key] = klass.new(cmd, args.join(' ')) keys[key] = klass.new(cmd, *args) # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) elsif TkComm._callback_entry?(keys[key]) keys[key] = klass.new(keys[key]) end } keys end |
#__get_validate_key2class ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/tk/validation.rb', line 37 def __get_validate_key2class k2c = {} __validation_class_list.each{|klass| klass._config_keys.each{|key| k2c[key.to_s] = klass } } k2c end |
#__validation_class_list ⇒ Object
32 33 34 35 |
# File 'lib/tk/validation.rb', line 32 def __validation_class_list # maybe need to override [] end |
#__validcmd_call(klass, key, *args, &b) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tk/validation.rb', line 18 def __validcmd_call(klass, key, *args, &b) return cget(key) if args.empty? && !b cmd = (b)? proc(&b) : args.shift if cmd.kind_of?(klass) configure(key, cmd) elsif !args.empty? configure(key, [cmd, args]) else configure(key, cmd) end end |