Sha256: fc364e34052fcbf7370fb001b047bc6fe0d8af9376c603180df5732ec935d70e
Contents?: true
Size: 945 Bytes
Versions: 1
Compression:
Stored size: 945 Bytes
Contents
class Shoes class Link < Span attr_reader :app, :parent, :gui DEFAULT_OPTS = { underline: true, stroke: ::Shoes::COLORS[:blue] } def initialize(app, parent, texts, opts={}, &blk) @app = app @parent = parent setup_block(blk, opts) opts = DEFAULT_OPTS.merge(opts) @gui = Shoes.backend_for(self, opts) super texts, opts end def setup_block(blk, opts) if blk @blk = blk elsif opts.include?(:click) if opts[:click].respond_to?(:call) @blk = opts[:click] else # Slightly awkward, but we need App, not InternalApp, to call visit @blk = Proc.new { app.app.visit(opts[:click]) } end end end def click(&blk) @blk = blk self end def execute_link @blk.call end def in_bounds?(x, y) @gui.in_bounds?(x, y) end def clear @gui.clear end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shoes-4.0.0.pre1 | lib/shoes/link.rb |