more updates!

This commit is contained in:
Paul Liverman III 2017-04-12 03:37:29 -07:00
parent ce13424075
commit 630cb51b59
11 changed files with 87 additions and 11 deletions

View File

@ -426,7 +426,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -144,7 +144,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -84,7 +84,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -491,7 +491,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -105,7 +105,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -99,6 +99,10 @@
<td class="summary">Event handler for <code>love.mousereleased()</code>.</td> <td class="summary">Event handler for <code>love.mousereleased()</code>.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#wheelmoved">wheelmoved (x, y)</a></td>
<td class="summary">Event handler for <code>love.wheelmoved()</code></td>
</tr>
<tr>
<td class="name" nowrap><a href="#keypressed">keypressed (key)</a></td> <td class="name" nowrap><a href="#keypressed">keypressed (key)</a></td>
<td class="summary">Event handler for <code>love.keypressed()</code>.</td> <td class="summary">Event handler for <code>love.keypressed()</code>.</td>
</tr> </tr>
@ -427,6 +431,37 @@ table.insert element.parent, element.parent\removeChild(element),</td>
</ul> </ul>
</dd>
<dt>
<a name = "wheelmoved"></a>
<strong>wheelmoved (x, y)</strong>
</dt>
<dd>
Event handler for <code>love.wheelmoved()</code>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">x</span>
<span class="types"><span class="type">number</span></span>
The distance the wheel moved on the x-axis.
</li>
<li><span class="parameter">y</span>
<span class="types"><span class="type">number</span></span>
The distance the wheel moved on the y-axis.
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
Was the event handled?
</ol>
</dd> </dd>
<dt> <dt>
<a name = "keypressed"></a> <a name = "keypressed"></a>
@ -723,7 +758,7 @@ table.insert element.parent, element.parent\removeChild(element),
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -126,7 +126,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2017-04-11 10:42:17 </i> <i style="float:right;">Last updated 2017-04-12 03:37:15 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -172,6 +172,9 @@ do
if self.data.draw == nil then if self.data.draw == nil then
self.data.draw = true self.data.draw = true
end end
if self.data.hoverable == nil then
self.data.hoverable = true
end
if not (self.data.type) then if not (self.data.type) then
self.data.type = "element" self.data.type = "element"
end end

View File

@ -23,6 +23,7 @@ class element
@data.h = 0 unless @data.h @data.h = 0 unless @data.h
@data.update = true if @data.update == nil @data.update = true if @data.update == nil
@data.draw = true if @data.draw == nil @data.draw = true if @data.draw == nil
@data.hoverable = true if @data.hoverable == nil
@data.type = "element" unless @data.type @data.type = "element" unless @data.type
@data.align = true if (@data.align == nil) and @parent @data.align = true if (@data.align == nil) and @parent
@data.vertical = "top" unless @data.vertical @data.vertical = "top" unless @data.vertical

View File

@ -213,9 +213,9 @@ pop.mousemoved = function(x, y, dx, dy, element)
if element == nil then if element == nil then
element = pop.screen element = pop.screen
end end
if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then if element.data.draw and element.data.hoverable and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then
pop.hovered = element pop.hovered = element
for i = #element.child, 1, -1 do for i = 1, #element.child do
pop.mousemoved(x, y, dx, dy, element.child[i]) pop.mousemoved(x, y, dx, dy, element.child[i])
end end
end end
@ -226,6 +226,13 @@ pop.mousemoved = function(x, y, dx, dy, element)
end end
pop.mousepressed = function(x, y, button, element) pop.mousepressed = function(x, y, button, element)
if not (element) then if not (element) then
if button == "wd" then
pop.wheelmoved(0, -1)
return true
elseif button == "wu" then
pop.wheelmoved(0, 1)
return true
end
log("mousepressed", x, y, button) log("mousepressed", x, y, button)
element = pop.screen element = pop.screen
end end
@ -281,6 +288,13 @@ pop.mousereleased = function(x, y, button, element)
end end
return clickedHandled, mousereleasedHandled return clickedHandled, mousereleasedHandled
end end
pop.wheelmoved = function(x, y)
log("wheelmoved", x, y)
if pop.hovered and pop.hovered.wheelmoved then
return pop.hovered:wheelmoved(x, y)
end
return false
end
pop.keypressed = function(key) pop.keypressed = function(key)
log("keypressed", key) log("keypressed", key)
local element = pop.focused local element = pop.focused

View File

@ -267,11 +267,11 @@ pop.draw = (element=pop.screen) ->
pop.mousemoved = (x, y, dx, dy, element=pop.screen) -> pop.mousemoved = (x, y, dx, dy, element=pop.screen) ->
-- first we find out if we're hovering over anything and set pop.hovered -- first we find out if we're hovering over anything and set pop.hovered
if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) if element.data.draw and element.data.hoverable and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h)
-- okay, we're over this element for sure, but let's check its children -- okay, we're over this element for sure, but let's check its children
pop.hovered = element pop.hovered = element
-- check in reverse order, it will set pop.hovered to any that match -- check in reverse order, it will set pop.hovered to any that match
for i = #element.child, 1, -1 for i = 1, #element.child
pop.mousemoved x, y, dx, dy, element.child[i] pop.mousemoved x, y, dx, dy, element.child[i]
--- @todo Implement a way for an element to attach itself to `love.mousemoved()` events? --- @todo Implement a way for an element to attach itself to `love.mousemoved()` events?
@ -297,6 +297,14 @@ pop.mousemoved = (x, y, dx, dy, element=pop.screen) ->
pop.mousepressed = (x, y, button, element) -> pop.mousepressed = (x, y, button, element) ->
-- start at the screen, print that we received an event -- start at the screen, print that we received an event
unless element unless element
-- take pre 0.10.0 wheel movement and pass it along
if button == "wd"
pop.wheelmoved 0, -1
return true
elseif button == "wu"
pop.wheelmoved 0, 1
return true
log "mousepressed", x, y, button log "mousepressed", x, y, button
element = pop.screen element = pop.screen
@ -374,6 +382,21 @@ pop.mousereleased = (x, y, button, element) ->
--- Event handler for `love.wheelmoved()`
--- @function wheelmoved
--- @tparam number x The distance the wheel moved on the x-axis.
--- @tparam number y The distance the wheel moved on the y-axis.
--- @treturn boolean Was the event handled?
pop.wheelmoved = (x, y) ->
log "wheelmoved", x, y
if pop.hovered and pop.hovered.wheelmoved
return pop.hovered\wheelmoved x, y
return false
--- Event handler for `love.keypressed()`. --- Event handler for `love.keypressed()`.
--- @function keypressed --- @function keypressed
--- @tparam string key The key that was pressed. --- @tparam string key The key that was pressed.