Class: Shoes::Link
- Defined in:
- shoes-core/lib/shoes/link.rb
Constant Summary collapse
Constants included from Common::Style
Common::Style::DEFAULT_STYLES, Common::Style::STYLE_GROUPS
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#blk ⇒ Object
readonly
Returns the value of attribute blk.
-
#gui ⇒ Object
readonly
Returns the value of attribute gui.
Attributes included from Common::Hover
Attributes inherited from Text
#color, #parent, #text_block, #texts, #to_s
Instance Method Summary collapse
- #click(&blk) ⇒ Object
- #hidden? ⇒ Boolean
- #in_bounds?(x, y) ⇒ Boolean
-
#initialize(my_app, texts, styles = {}, blk = nil) ⇒ Link
constructor
A new instance of Link.
- #links ⇒ Object
- #pass_coordinates? ⇒ Boolean
-
#register_click(blk) ⇒ Object
Doesn’t use Common::Clickable because of URL flavor option clicks.
- #release(&blk) ⇒ Object
- #remove ⇒ Object
- #visible? ⇒ Boolean
Methods included from Common::Style
#applicable_app_styles, #create_style_hash, included, #style, #style_init
Methods included from Common::Stroke
Methods included from Common::SafelyEvaluate
Methods included from Common::Hover
#add_mouse_hover_control, #apply_style_from_hover_class, #apply_style_from_pre_hover, create_hover_class, #eval_hover_block, #hover, #hover_class, #hovered?, #leave, #mouse_hovered, #mouse_left
Methods included from Common::Fill
Methods inherited from Span
Methods included from Common::LinkFinder
Methods included from Common::Inspect
Constructor Details
#initialize(my_app, texts, styles = {}, blk = nil) ⇒ Link
Returns a new instance of Link.
15 16 17 18 19 20 21 22 |
# File 'shoes-core/lib/shoes/link.rb', line 15 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 |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
11 12 13 |
# File 'shoes-core/lib/shoes/link.rb', line 11 def app @app end |
#blk ⇒ Object (readonly)
Returns the value of attribute blk.
11 12 13 |
# File 'shoes-core/lib/shoes/link.rb', line 11 def blk @blk end |
#gui ⇒ Object (readonly)
Returns the value of attribute gui.
11 12 13 |
# File 'shoes-core/lib/shoes/link.rb', line 11 def gui @gui end |
Instance Method Details
#click(&blk) ⇒ Object
38 39 40 41 42 |
# File 'shoes-core/lib/shoes/link.rb', line 38 def click(&blk) @gui.click blk if blk @blk = blk self end |
#hidden? ⇒ Boolean
61 62 63 |
# File 'shoes-core/lib/shoes/link.rb', line 61 def hidden? text_block_guard && @text_block.hidden? end |
#in_bounds?(x, y) ⇒ Boolean
53 54 55 |
# File 'shoes-core/lib/shoes/link.rb', line 53 def in_bounds?(x, y) @gui.in_bounds?(x, y) end |
#links ⇒ Object
69 70 71 |
# File 'shoes-core/lib/shoes/link.rb', line 69 def links [self] end |
#pass_coordinates? ⇒ Boolean
49 50 51 |
# File 'shoes-core/lib/shoes/link.rb', line 49 def pass_coordinates? false end |
#register_click(blk) ⇒ Object
Doesn’t use Common::Clickable because of URL flavor option clicks
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'shoes-core/lib/shoes/link.rb', line 25 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 |
#release(&blk) ⇒ Object
44 45 46 47 |
# File 'shoes-core/lib/shoes/link.rb', line 44 def release(&blk) @gui.release blk if blk self end |
#remove ⇒ Object
57 58 59 |
# File 'shoes-core/lib/shoes/link.rb', line 57 def remove @gui.remove end |
#visible? ⇒ Boolean
65 66 67 |
# File 'shoes-core/lib/shoes/link.rb', line 65 def visible? text_block_guard && @text_block.visible? end |