Class: TkValidateCommand

Inherits:
Object show all
Extended by:
TkComm
Includes:
TkComm
Defined in:
lib/tk/validation.rb

Defined Under Namespace

Classes: ValidateArgs

Constant Summary

Constants included from TkComm

TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames

Constants included from TkUtil

TkUtil::None, TkUtil::RELEASE_DATE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TkComm

_at, _callback_entry?, _callback_entry_class?, _curr_cmd_id, _fromUTF8, _genobj_for_tkwidget, _next_cmd_id, _toUTF8, array2tk_list, bind, bind_all, bind_append, bind_append_all, bind_remove, bind_remove_all, bindinfo, bindinfo_all, bool, image_obj, install_cmd, install_cmd, list, num_or_nil, num_or_str, number, procedure, simplelist, slice_ary, string, subst, tk_tcl2ruby, uninstall_cmd, uninstall_cmd, window

Methods included from TkEvent

#install_bind, #install_bind_for_event_class

Methods included from TkUtil

#_conv_args, _conv_args, #_fromUTF8, #_get_eval_enc_str, _get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, #bool, bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, #num_or_nil, num_or_nil, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd, untrust

Constructor Details

#initialize(cmd = Proc.new, *args) ⇒ TkValidateCommand

Returns a new instance of TkValidateCommand.



335
336
337
# File 'lib/tk/validation.rb', line 335

def initialize(cmd = Proc.new, *args)
  _initialize_for_cb_class(self.class::ValidateArgs, cmd, *args)
end

Class Method Details

._config_keysObject



292
293
294
295
# File 'lib/tk/validation.rb', line 292

def self._config_keys
  # array of config-option key (string or symbol)
  ['vcmd', 'validatecommand', 'invcmd', 'invalidcommand']
end

Instance Method Details

#_initialize_for_cb_class(klass, cmd = Proc.new, *args) ⇒ Object



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/tk/validation.rb', line 297

def _initialize_for_cb_class(klass, cmd = Proc.new, *args)
  extra_args_tbl = klass._get_extra_args_tbl

  if args.compact.size > 0
    args.map!{|arg| klass._sym2subst(arg)}
    args = args.join(' ')
    keys = klass._get_subst_key(args)
    if cmd.kind_of?(String)
      id = cmd
    elsif cmd.kind_of?(TkCallbackEntry)
      @id = install_cmd(cmd)
    else
      @id = install_cmd(proc{|*arg|
           ex_args = []
           extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
           klass.ret_val(cmd.call(
             *(ex_args.concat(klass.scan_args(keys, arg)))
           ))
      }) + ' ' + args
    end
  else
    keys, args = klass._get_all_subst_keys
    if cmd.kind_of?(String)
      id = cmd
    elsif cmd.kind_of?(TkCallbackEntry)
      @id = install_cmd(cmd)
    else
      @id = install_cmd(proc{|*arg|
           ex_args = []
           extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
           klass.ret_val(cmd.call(
             *(ex_args << klass.new(*klass.scan_args(keys, arg)))
           ))
      }) + ' ' + args
    end
  end
end

#to_evalObject



339
340
341
# File 'lib/tk/validation.rb', line 339

def to_eval
  @id
end