Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
alias button num alias delta wheel_delta alias root rootwin_id alias rootx x_root alias root_x x_root alias rooty y_root alias root_y y_root alias sendevent send_event
the subst-key string will be converted to a bytecode (128+idx).
# File tk/lib/tk/event.rb, line 121
def self.group_flag(id)
TYPE_GROUP_TBL[id] || 0
end
# File tk/lib/tk/event.rb, line 252
def generate(win, modkeys={})
klass = self.class
if modkeys.has_key?(:type) || modkeys.has_key?('type')
modkeys = TkComm._symbolkey2str(modkeys)
type_id = modkeys.delete('type')
else
type_id = self.type
end
type_name = klass.type_name(type_id)
unless type_name
fail RuntimeError, "type_id #{type_id} is invalid"
end
group_flag = klass.group_flag(type_id)
opts = valid_for_generate(group_flag)
modkeys.each{|key, val|
if val
opts[key.to_s] = val
else
opts.delete(key.to_s)
end
}
if group_flag != Grp::KEY
Tk.event_generate(win, type_name, opts)
else
# If type is KEY event, focus should be set to target widget.
# If not set, original widget will get the same event.
# That will make infinite loop.
w = Tk.tk_call_without_enc('focus')
begin
Tk.tk_call_without_enc('focus', win)
Tk.event_generate(win, type_name, opts)
ensure
Tk.tk_call_without_enc('focus', w)
end
end
end
# File tk/lib/tk/event.rb, line 217
def valid_fields(group_flag=nil)
group_flag = self.class.group_flag(self.type) unless group_flag
fields = {}
FIELD_FLAG.each{|key, flag|
next if (flag & group_flag) == 0
begin
val = self.__send__(key)
rescue
next
end
# next if !val || val == '??'
next if !val || (val == '??' && (flag & Grp::STRING_DATA))
fields[key] = val
}
fields
end
# File tk/lib/tk/event.rb, line 236
def valid_for_generate(group_flag=nil)
fields = valid_fields(group_flag)
FIELD_OPERATION.each{|key, cmd|
next unless fields.has_key?(key)
val = FIELD_OPERATION[key].call(fields[key])
if val
fields[key] = val
else
fields.delete(key)
end
}
fields
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.