Sha256: 339b2dee70a0fa2c1eb5a8c3365e4a5d3e21c615546178e82f23fa3b0a616f3b
Contents?: true
Size: 1.67 KB
Versions: 4
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true class Shoes class Link < Span include Common::Fill include Common::Hover include Common::SafelyEvaluate include Common::Stroke include Common::Style attr_reader :app, :gui, :blk style_with :common_styles, :text_block_styles STYLES = { underline: true, stroke: ::Shoes::COLORS[:blue], fill: nil }.freeze def initialize(my_app, texts, styles = {}, blk = nil) @app = my_app style_init styles @gui = Shoes.backend_for self register_click blk super texts, @style end # Doesn't use Common::Clickable because of URL flavor option clicks def register_click(blk) if blk.nil? blk = if @style[:click].respond_to? :call @style[:click] else # Slightly awkward, but we need App, not InternalApp, to call visit proc { app.app.visit @style[:click] } end end click(&blk) end def click(&blk) @gui.click blk if blk @blk = blk self end def release(&blk) @gui.release blk if blk self end def pass_coordinates? false end def in_bounds?(x, y) @gui.in_bounds?(x, y) end def remove @gui.remove end def hidden? text_block_guard && @text_block.hidden? end def visible? text_block_guard && @text_block.visible? end def links [self] end private def text_block_guard if @text_block true else @app.warn 'Stray link without TextBlock detected! Links have to be part of a text block like a para or title' false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
shoes-core-4.0.0.pre12 | lib/shoes/link.rb |
shoes-core-4.0.0.pre11 | lib/shoes/link.rb |
shoes-core-4.0.0.pre10 | lib/shoes/link.rb |
shoes-core-4.0.0.pre9 | lib/shoes/link.rb |