Sha256: 778b650427f92e290edc504c91c64e1c31d6d3b880616cce62743e1582d9d4b2
Contents?: true
Size: 1.47 KB
Versions: 6
Compression:
Stored size: 1.47 KB
Contents
module CyberarmEngine class Element class Button < Label def initialize(text, options = {}, block = nil) super(text, options, block) @style.background_canvas.background = default(:background) end def render draw_text end def draw_text @text.draw end def enter(sender) @focus = false unless window.button_down?(Gosu::MsLeft) if @focus @style.background_canvas.background = default(:active, :background) @text.color = default(:active, :color) else @style.background_canvas.background = default(:hover, :background) @text.color = default(:hover, :color) end return :handled end def left_mouse_button(sender, x, y) @focus = true @style.background_canvas.background = default(:active, :background) window.current_state.focus = self @text.color = default(:active, :color) return :handled end def released_left_mouse_button(sender,x, y) enter(sender) return :handled end def clicked_left_mouse_button(sender, x, y) @block.call(self) if @block return :handled end def leave(sender) @style.background_canvas.background = default(:background) @text.color = default(:color) return :handled end def blur(sender) @focus = false return :handled end end end end
Version data entries
6 entries across 6 versions & 1 rubygems