mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
more updates!
This commit is contained in:
parent
ce13424075
commit
630cb51b59
@ -426,7 +426,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -144,7 +144,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -84,7 +84,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -491,7 +491,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -105,7 +105,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -99,6 +99,10 @@
|
||||
<td class="summary">Event handler for <code>love.mousereleased()</code>.</td>
|
||||
</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="summary">Event handler for <code>love.keypressed()</code>.</td>
|
||||
</tr>
|
||||
@ -427,6 +431,37 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
</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>
|
||||
<dt>
|
||||
<a name = "keypressed"></a>
|
||||
@ -723,7 +758,7 @@ table.insert element.parent, element.parent\removeChild(element),
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -126,7 +126,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<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="container" -->
|
||||
</body>
|
||||
|
@ -172,6 +172,9 @@ do
|
||||
if self.data.draw == nil then
|
||||
self.data.draw = true
|
||||
end
|
||||
if self.data.hoverable == nil then
|
||||
self.data.hoverable = true
|
||||
end
|
||||
if not (self.data.type) then
|
||||
self.data.type = "element"
|
||||
end
|
||||
|
@ -23,6 +23,7 @@ class element
|
||||
@data.h = 0 unless @data.h
|
||||
@data.update = true if @data.update == nil
|
||||
@data.draw = true if @data.draw == nil
|
||||
@data.hoverable = true if @data.hoverable == nil
|
||||
@data.type = "element" unless @data.type
|
||||
@data.align = true if (@data.align == nil) and @parent
|
||||
@data.vertical = "top" unless @data.vertical
|
||||
|
18
init.lua
18
init.lua
@ -213,9 +213,9 @@ pop.mousemoved = function(x, y, dx, dy, element)
|
||||
if element == nil then
|
||||
element = pop.screen
|
||||
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
|
||||
for i = #element.child, 1, -1 do
|
||||
for i = 1, #element.child do
|
||||
pop.mousemoved(x, y, dx, dy, element.child[i])
|
||||
end
|
||||
end
|
||||
@ -226,6 +226,13 @@ pop.mousemoved = function(x, y, dx, dy, element)
|
||||
end
|
||||
pop.mousepressed = function(x, y, button, element)
|
||||
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)
|
||||
element = pop.screen
|
||||
end
|
||||
@ -281,6 +288,13 @@ pop.mousereleased = function(x, y, button, element)
|
||||
end
|
||||
return clickedHandled, mousereleasedHandled
|
||||
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)
|
||||
log("keypressed", key)
|
||||
local element = pop.focused
|
||||
|
27
init.moon
27
init.moon
@ -267,11 +267,11 @@ pop.draw = (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
|
||||
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
|
||||
pop.hovered = element
|
||||
-- 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]
|
||||
|
||||
--- @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) ->
|
||||
-- start at the screen, print that we received an event
|
||||
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
|
||||
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()`.
|
||||
--- @function keypressed
|
||||
--- @tparam string key The key that was pressed.
|
||||
|
Loading…
Reference in New Issue
Block a user