Class: Hokusai::Blocks::Selectable
Instance Attribute Summary collapse
#node, #provides, #publisher
Instance Method Summary
collapse
#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, inject, inject!, #method_missing, mount, #on_resize, provide, provides, #render, style, styles_get, template, template_from_file, template_get, #update, use, uses
Constructor Details
#initialize(**args) ⇒ Selectable
Returns a new instance of Selectable.
33
34
35
36
37
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 33
def initialize(**args)
@selection = Hokusai::Util::Selection.new
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hokusai::Block
Instance Attribute Details
#selection ⇒ Object
Returns the value of attribute selection.
31
32
33
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 31
def selection
@selection
end
|
Instance Method Details
#cursor(index) ⇒ Object
71
72
73
74
75
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 71
def cursor(index)
return if selection.cursor.nil?
selection.cursor[index]
end
|
#cursor_height ⇒ Object
63
64
65
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 63
def cursor_height
cursor(3)
end
|
#cursor_show ⇒ Object
67
68
69
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 67
def cursor_show
!selection.cursor.nil?
end
|
#cursor_x ⇒ Object
55
56
57
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 55
def cursor_x
cursor(0)
end
|
#cursor_y ⇒ Object
59
60
61
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 59
def cursor_y
cursor(1)
end
|
#start_selection(event) ⇒ Object
39
40
41
42
43
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 39
def start_selection(event)
if event.left.down && !selection.active?
selection.start(event.pos.x, event.pos.y)
end
end
|
#update_selection(event) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'ui/src/hokusai/blocks/selectable.rb', line 45
def update_selection(event)
return unless selection.active?
if event.left[:up]
selection.freeze!
elsif event.left[:down]
selection.stop(event.pos.x, event.pos.y)
end
end
|