mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
docs updates
This commit is contained in:
parent
37a2cc125b
commit
e548456366
@ -48,6 +48,31 @@
|
||||
--- LÖVE version.)
|
||||
--- @treturn boolean Was the event handled?
|
||||
|
||||
--- **Optional**: Called from `pop.mousereleased()` if a mouse button was
|
||||
--- pressed and then released over your element.
|
||||
---
|
||||
--- **Note**: Your element must be visible (`data.draw` is true) for this method
|
||||
--- to be called.
|
||||
--- @function clicked
|
||||
--- @tparam integer x The x coordinate of the mouse click relative to the
|
||||
--- element.
|
||||
--- @tparam integer y The y coordinate of the mouse click relative to the
|
||||
--- element.
|
||||
--- @tparam ?string|integer button The mouse button clicked. (Type varies by
|
||||
--- LÖVE version.)
|
||||
--- @treturn boolean Was the event handled?
|
||||
|
||||
--- **Optional**: Called from `pop.mousereleased()` if a mouse button was
|
||||
--- released over your element.
|
||||
--- @function mousereleased
|
||||
--- @tparam integer x The x coordinate of the mouse release relative to the
|
||||
--- element.
|
||||
--- @tparam integer y The y coordinate of the mouse release relative to the
|
||||
--- element.
|
||||
--- @tparam ?string|integer button The mouse button released. (Type varies by
|
||||
--- LÖVE version.)
|
||||
--- @treturn boolean Was the event handled?
|
||||
|
||||
|
||||
|
||||
--- The parent element of this element.
|
||||
@ -76,15 +101,10 @@
|
||||
|
||||
|
||||
|
||||
pop.mousereleased = (x, y, button, element) ->
|
||||
if element.clicked and element.data.draw
|
||||
clickedHandled = element\clicked x - element.data.x, y - element.data.y, button
|
||||
if element.mousereleased
|
||||
mousereleasedHandled = element\mousereleased x - element.data.x, y - element.data.y, button
|
||||
|
||||
-- if we clicked, we're focused!
|
||||
if clickedHandled
|
||||
pop.focused = element
|
||||
-- @todo Document keypressed method
|
||||
-- @todo Document keyreleased method
|
||||
-- @todo Document textinput method
|
||||
-- @todo Document debugDraw method
|
||||
|
||||
pop.keypressed = (key) ->
|
||||
print "keypressed", key
|
||||
@ -119,32 +139,3 @@ pop.textinput = (text) ->
|
||||
pop.debugDraw = (element=pop.screen) ->
|
||||
if element.debugDraw
|
||||
element\debugDraw!
|
||||
else
|
||||
graphics.setLineWidth 1
|
||||
graphics.setLineColor 0, 0, 0, 100
|
||||
graphics.rectangle "fill", element.x, element.y, element.w, element.h
|
||||
graphics.setColor 150, 150, 150, 150
|
||||
graphics.rectangle "line", element.x, element.y, element.w, element.h
|
||||
graphics.setColor 200, 200, 200, 255
|
||||
graphics.print ".", element.x, element.y
|
||||
|
||||
for i = 1, #element.child
|
||||
pop.debugDraw element.child[i]
|
||||
|
||||
pop.printElementTree = (element=pop.screen, depth=0) ->
|
||||
cls = element.__class.__name
|
||||
|
||||
if cls == "text"
|
||||
cls = cls .. " (\"#{element\getText!\gsub "\n", "\\n"}\")"
|
||||
elseif cls == "box"
|
||||
bg = element\getBackground!
|
||||
|
||||
if type(bg) == "table"
|
||||
bg = "#{bg[1]}, #{bg[2]}, #{bg[3]}, #{bg[4]}"
|
||||
|
||||
cls = cls .. " (#{bg})"
|
||||
|
||||
print string.rep("-", depth) .. " #{cls}"
|
||||
|
||||
for i = 1, #element.child
|
||||
pop.printElementTree element.child[i], depth + 1
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Issues">Issues</a></li>
|
||||
<li><a href="#Methods">Methods</a></li>
|
||||
</ul>
|
||||
|
||||
@ -64,11 +65,18 @@
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Issues">Issues</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#element.new-todo5">element.new-todo5</a></td>
|
||||
<td class="summary">if data, do stuff about it</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Methods">Methods</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#element.new">element.new (self, parent)</a></td>
|
||||
<td class="summary">Constructor expects nothing?</td>
|
||||
<td class="name" nowrap><a href="#element.new">element.new (self, @, @)</a></td>
|
||||
<td class="summary">Constructor expects nothing, or a data table describing it.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -76,15 +84,33 @@
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Issues"></a>Issues</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "element.new-todo5"></a>
|
||||
<strong>element.new-todo5</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
if data, do stuff about it
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "element.new"></a>
|
||||
<strong>element.new (self, parent)</strong>
|
||||
<strong>element.new (self, @, @)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Constructor expects nothing?
|
||||
Constructor expects nothing, or a data table describing it.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@ -94,7 +120,12 @@
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">parent</span>
|
||||
<li><span class="parameter">@</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">@</span>
|
||||
|
||||
|
||||
|
||||
@ -113,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 2016-08-21 00:47:30 </i>
|
||||
<i style="float:right;">Last updated 2016-08-22 18:19:38 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -79,7 +79,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 2016-08-21 00:47:30 </i>
|
||||
<i style="float:right;">Last updated 2016-08-22 18:19:38 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -92,6 +92,16 @@
|
||||
<td class="summary"><strong>Optional</strong>: Called from <code>pop.mousepressed()</code> if a mouse button was pressed
|
||||
over your element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#clicked">clicked (x, y, button)</a></td>
|
||||
<td class="summary"><strong>Optional</strong>: Called from <code>pop.mousereleased()</code> if a mouse button was
|
||||
pressed and then released over your element.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#mousereleased">mousereleased (x, y, button)</a></td>
|
||||
<td class="summary"><strong>Optional</strong>: Called from <code>pop.mousereleased()</code> if a mouse button was
|
||||
released over your element.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
@ -285,6 +295,87 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "clicked"></a>
|
||||
<strong>clicked (x, y, button)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
<strong>Optional</strong>: Called from <code>pop.mousereleased()</code> if a mouse button was
|
||||
pressed and then released over your element. </p>
|
||||
|
||||
<p> <strong>Note</strong>: Your element must be visible (<code>data.draw</code> is true) for this method
|
||||
to be called.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">x</span>
|
||||
<span class="types"><span class="type">integer</span></span>
|
||||
The x coordinate of the mouse click relative to the
|
||||
element.
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
<span class="types"><span class="type">integer</span></span>
|
||||
The y coordinate of the mouse click relative to the
|
||||
element.
|
||||
</li>
|
||||
<li><span class="parameter">button</span>
|
||||
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">integer</span></span>
|
||||
The mouse button clicked. (Type varies by
|
||||
LÖVE version.)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Was the event handled?
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "mousereleased"></a>
|
||||
<strong>mousereleased (x, y, button)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
<strong>Optional</strong>: Called from <code>pop.mousereleased()</code> if a mouse button was
|
||||
released over your element.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">x</span>
|
||||
<span class="types"><span class="type">integer</span></span>
|
||||
The x coordinate of the mouse release relative to the
|
||||
element.
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
<span class="types"><span class="type">integer</span></span>
|
||||
The y coordinate of the mouse release relative to the
|
||||
element.
|
||||
</li>
|
||||
<li><span class="parameter">button</span>
|
||||
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">integer</span></span>
|
||||
The mouse button released. (Type varies by
|
||||
LÖVE version.)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">boolean</span></span>
|
||||
Was the event handled?
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
@ -395,7 +486,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 2016-08-21 00:47:30 </i>
|
||||
<i style="float:right;">Last updated 2016-08-22 18:19:38 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -71,7 +71,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 2016-08-21 00:47:30 </i>
|
||||
<i style="float:right;">Last updated 2016-08-22 18:19:38 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -665,7 +665,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 2016-08-21 00:47:30 </i>
|
||||
<i style="float:right;">Last updated 2016-08-22 18:19:38 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -125,7 +125,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 2016-08-21 00:47:30 </i>
|
||||
<i style="float:right;">Last updated 2016-08-22 18:19:38 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -6,7 +6,12 @@ do
|
||||
}
|
||||
_base_0.__index = _base_0
|
||||
_class_0 = setmetatable({
|
||||
__init = function(self, parent) end,
|
||||
__init = function(self, parent, data)
|
||||
if data == nil then
|
||||
data = { }
|
||||
end
|
||||
self.parent, self.data = parent, data
|
||||
end,
|
||||
__base = _base_0,
|
||||
__name = "element"
|
||||
}, {
|
||||
|
@ -4,9 +4,9 @@
|
||||
--- @license The MIT License (MIT)
|
||||
|
||||
class element
|
||||
--- Constructor expects nothing?
|
||||
new: (parent) =>
|
||||
--do stuff
|
||||
--- Constructor expects nothing, or a data table describing it.
|
||||
new: (@parent, @data={}) =>
|
||||
--- @todo if data, do stuff about it
|
||||
|
||||
setSize: =>
|
||||
--do more stuff!
|
||||
|
6
init.lua
6
init.lua
@ -248,11 +248,11 @@ pop.debugDraw = function(element)
|
||||
else
|
||||
graphics.setLineWidth(1)
|
||||
graphics.setLineColor(0, 0, 0, 100)
|
||||
graphics.rectangle("fill", element.x, element.y, element.w, element.h)
|
||||
graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h)
|
||||
graphics.setColor(150, 150, 150, 150)
|
||||
graphics.rectangle("line", element.x, element.y, element.w, element.h)
|
||||
graphics.rectangle("line", element.data.x, element.data.y, element.data.w, element.data.h)
|
||||
graphics.setColor(200, 200, 200, 255)
|
||||
graphics.print(".", element.x, element.y)
|
||||
graphics.print(".", element.data.x, element.data.y)
|
||||
end
|
||||
for i = 1, #element.child do
|
||||
pop.debugDraw(element.child[i])
|
||||
|
10
init.moon
10
init.moon
@ -142,7 +142,7 @@ pop.create = (element, parent=pop.screen, ...) ->
|
||||
element = pop.elements[element](parent, ...)
|
||||
insert parent.child, element
|
||||
insert parent.data.child, element.data
|
||||
element.parent = parent
|
||||
element.parent = parent --this should already have been set by the element, this is here as a precaution
|
||||
element.data.parent = parent.data
|
||||
-- if explicitly no parent, just create the element
|
||||
elseif parent == false
|
||||
@ -154,7 +154,7 @@ pop.create = (element, parent=pop.screen, ...) ->
|
||||
element = pop.elements[element](pop.screen, parent, ...)
|
||||
insert pop.screen.child, element
|
||||
insert pop.screen.data.child, element.data
|
||||
element.parent = pop.screen
|
||||
element.parent = pop.screen --this should already have been set by the element, this is here as a precaution
|
||||
element.data.parent = pop.screen.data
|
||||
|
||||
return element
|
||||
@ -369,11 +369,11 @@ pop.debugDraw = (element=pop.screen) ->
|
||||
else
|
||||
graphics.setLineWidth 1
|
||||
graphics.setLineColor 0, 0, 0, 100
|
||||
graphics.rectangle "fill", element.x, element.y, element.w, element.h
|
||||
graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h
|
||||
graphics.setColor 150, 150, 150, 150
|
||||
graphics.rectangle "line", element.x, element.y, element.w, element.h
|
||||
graphics.rectangle "line", element.data.x, element.data.y, element.data.w, element.data.h
|
||||
graphics.setColor 200, 200, 200, 255
|
||||
graphics.print ".", element.x, element.y
|
||||
graphics.print ".", element.data.x, element.data.y
|
||||
|
||||
for i = 1, #element.child
|
||||
pop.debugDraw element.child[i]
|
||||
|
Loading…
Reference in New Issue
Block a user