mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 13:12:34 +00:00
CheckBox now works as expected
This commit is contained in:
@@ -1,19 +1,20 @@
|
|||||||
module CyberarmEngine
|
module CyberarmEngine
|
||||||
class CheckBox < Flow
|
class CheckBox < Flow
|
||||||
def initialize(text, options, block = nil)
|
def initialize(text, options, block = nil)
|
||||||
super(options = {}, block = nil)
|
super({}, block = nil)
|
||||||
|
options[:toggled] = options[:checked]
|
||||||
|
|
||||||
@toggle_button = ToggleButton.new(options)
|
@toggle_button = ToggleButton.new(options)
|
||||||
@label = Label.new(text, options)
|
@label = Label.new(text, options)
|
||||||
|
|
||||||
|
define_label_singletons
|
||||||
|
|
||||||
add(@toggle_button)
|
add(@toggle_button)
|
||||||
add(@label)
|
add(@label)
|
||||||
|
|
||||||
@width = @toggle_button.width + @label.width
|
@width = @toggle_button.width + @label.width
|
||||||
@height = @toggle_button.height + @label.height
|
@height = @toggle_button.height + @label.height
|
||||||
|
|
||||||
@background_color = Gosu::Color::RED
|
|
||||||
|
|
||||||
recalculate
|
recalculate
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,7 +28,35 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clicked_left_mouse_button(sender, x, y)
|
def clicked_left_mouse_button(sender, x, y)
|
||||||
@toggle_button.toggled = !@toggle_button.toggled
|
@toggle_button.clicked_left_mouse_button(sender, x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
def define_label_singletons
|
||||||
|
@label.define_singleton_method(:_toggle_button) do |button|
|
||||||
|
@_toggle_button = button
|
||||||
|
end
|
||||||
|
|
||||||
|
@label._toggle_button(@toggle_button)
|
||||||
|
|
||||||
|
@label.define_singleton_method(:holding_left_mouse_button) do |sender, x, y|
|
||||||
|
@_toggle_button.holding_left_mouse_button(sender, x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
@label.define_singleton_method(:released_left_mouse_button) do |sender, x, y|
|
||||||
|
@_toggle_button.released_left_mouse_button(sender, x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
@label.define_singleton_method(:clicked_left_mouse_button) do |sender, x, y|
|
||||||
|
@_toggle_button.clicked_left_mouse_button(sender, x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
@label.define_singleton_method(:enter) do |sender|
|
||||||
|
@_toggle_button.enter(sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
@label.define_singleton_method(:leave) do |sender|
|
||||||
|
@_toggle_button.leave(sender)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user