Added support for passing a filter method/proc to EditLine

This commit is contained in:
2020-06-23 09:51:36 -05:00
parent d392d8249d
commit 2a8e852b15

View File

@@ -2,6 +2,7 @@ module CyberarmEngine
class Element
class EditLine < Button
def initialize(text, options = {}, block = nil)
@filter = options.delete(:filter)
super(text, options, block)
@type = default(:type)
@@ -17,6 +18,14 @@ module CyberarmEngine
@text_input.text = text
@last_text_value = text
if @filter && @filter.respond_to?(:call)
@text_input.instance_variable_set(:@filter, @filter)
def @text_input.filter(text_in)
@filter.call(text_in)
end
end
@offset_x, @offset_y = 0, 0
event(:begin_drag)