Class: Hokusai::Automation::DriverCommands::TriggerMouseDrag

Inherits:
Base
  • Object
show all
Includes:
MouseMethods
Defined in:
ui/src/hokusai/automation/driver_commands/trigger_mouse.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#last_parent, #request_id, #state, #status

Instance Method Summary collapse

Methods included from MouseMethods

#trigger_mouse

Methods inherited from Base

#matches_block, #matches_blocks, #mouse_center, #mouse_move

Constructor Details

#initialize(hash) ⇒ TriggerMouseDrag

Returns a new instance of TriggerMouseDrag.



138
139
140
141
142
143
144
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 138

def initialize(hash)
  @dragging = false
  @cursory_y = 0.0
  @button = 0

  super
end

Instance Attribute Details

#buttonObject

Returns the value of attribute button.



136
137
138
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 136

def button
  @button
end

#cursory_yObject

Returns the value of attribute cursory_y.



136
137
138
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 136

def cursory_y
  @cursory_y
end

#draggingObject

Returns the value of attribute dragging.



136
137
138
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 136

def dragging
  @dragging
end

Instance Method Details

#execute(blocks, canvas, input) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 164

def execute(blocks, canvas, input)
  if matches_block(blocks[0])
    local_x = x || canvas.x + (canvas.width / 2.0)
    local_y = y || canvas.y + (canvas.height / 2.0)

    if cursor_y < local_y && dragging
      trigger_mouse(input, down: true)
      mouse_move(local_x, cursor_y, input)

      self.cursor_y += 2.0
    elsif !dragging
      trigger_mouse(input, clicked: true)

      self.dragging = true
    else
      self.dragging = false
      
      done!
    end
  end
end

#locationObject



146
147
148
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 146

def location
  state[:uuid]
end

#on_completeObject



158
159
160
161
162
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 158

def on_complete
  return false if dragging

  true
end

#xObject



150
151
152
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 150

def x
  state[:x]
end

#yObject



154
155
156
# File 'ui/src/hokusai/automation/driver_commands/trigger_mouse.rb', line 154

def y
  state[:y]
end