TkValidation (Module)

In: tk/lib/tk/validation.rb

Methods

Public Instance methods

[Source]

# File tk/lib/tk/validation.rb, line 100
  def configure(slot, value=TkComm::None)
    if slot.kind_of? Hash
      slot = _symbolkey2str(slot)
      if slot['vcmd'].kind_of? Array
        cmd, *args = slot['vcmd']
        slot['vcmd'] = ValidateCmd.new(cmd, args.join(' '))
      elsif slot['vcmd'].kind_of? Proc
        slot['vcmd'] = ValidateCmd.new(slot['vcmd'])
      end
      if slot['validatecommand'].kind_of? Array
        cmd, *args = slot['validatecommand']
        slot['validatecommand'] = ValidateCmd.new(cmd, args.join(' '))
      elsif slot['validatecommand'].kind_of? Proc
        slot['validatecommand'] = ValidateCmd.new(slot['validatecommand'])
      end
      if slot['invcmd'].kind_of? Array
        cmd, *args = slot['invcmd']
        slot['invcmd'] = ValidateCmd.new(cmd, args.join(' '))
      elsif slot['invcmd'].kind_of? Proc
        slot['invcmd'] = ValidateCmd.new(slot['invcmd'])
      end
      if slot['invalidcommand'].kind_of? Array
        cmd, *args = slot['invalidcommand']
        slot['invalidcommand'] = ValidateCmd.new(cmd, args.join(' '))
      elsif slot['invalidcommand'].kind_of? Proc
        slot['invalidcommand'] = ValidateCmd.new(slot['invalidcommand'])
      end
      super(slot)
    else
      if (slot == 'vcmd' || slot == :vcmd || 
          slot == 'validatecommand' || slot == :validatecommand || 
          slot == 'invcmd' || slot == :invcmd || 
          slot == 'invalidcommand' || slot == :invalidcommand)
        if value.kind_of? Array
          cmd, *args = value
          value = ValidateCmd.new(cmd, args.join(' '))
        elsif value.kind_of? Proc
          value = ValidateCmd.new(value)
        end
      end
      super(slot, value)
    end
    self
  end

[Source]

# File tk/lib/tk/validation.rb, line 156
  def invalidcommand(cmd = Proc.new, args = nil)
    if cmd.kind_of?(ValidateCmd)
      configure('invalidcommand', cmd)
    elsif args
      configure('invalidcommand', [cmd, args])
    else
      configure('invalidcommand', cmd)
    end
  end
invcmd(cmd = Proc.new, args = nil)

Alias for invalidcommand

[Source]

# File tk/lib/tk/validation.rb, line 145
  def validatecommand(cmd = Proc.new, args = nil)
    if cmd.kind_of?(ValidateCmd)
      configure('validatecommand', cmd)
    elsif args
      configure('validatecommand', [cmd, args])
    else
      configure('validatecommand', cmd)
    end
  end
vcmd(cmd = Proc.new, args = nil)

Alias for validatecommand

[Validate]