mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Not important updates
This commit is contained in:
@@ -93,6 +93,7 @@ function button:draw()
|
||||
end
|
||||
---Check if current position is hovering the button, if yes, set ``self._hovering`` to true and return true
|
||||
function button:isHovering(x,y)
|
||||
if not y then self._hovering = false; return false end
|
||||
if
|
||||
x >= self.x and
|
||||
y >= self.y and
|
||||
@@ -111,7 +112,10 @@ function button:press()
|
||||
end
|
||||
---Trigger release action, don't need ``self._hovering`` to ``true``
|
||||
function button:release()
|
||||
self.codeWhenReleased()
|
||||
if self._hovering then
|
||||
self.codeWhenReleased()
|
||||
self._hovering = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -122,18 +126,19 @@ local BUTTON = {}
|
||||
---@return nil
|
||||
---Validate the provided data, will be called by ``BUTTON.new`` and ``BUTTON.setDefaultOption``<br>
|
||||
---***WARNING! THIS FUNCTION WILL RAISE EXCEPTION IF DATA IS INVALID!***
|
||||
function BUTTON.checkDataValidation(D)
|
||||
-- <SAFE TO IGNORE>
|
||||
assert(type(D.text) == "string" == "string","[text] is missing, or you just passed an empty data?")
|
||||
|
||||
assert(type(D.x) == "number" , "[x] must be a integer")
|
||||
assert(type(D.y) == "number" , "[y] must be a integer")
|
||||
assert(type(D.w) == "number" and D.w > 0, "[w] must be a positive integer")
|
||||
assert(type(D.h) == "number" and D.h > 0, "[h] must be a positive integer")
|
||||
-- </>
|
||||
function BUTTON.checkDataValidation(D, safe)
|
||||
if not safe then
|
||||
assert(type(D.text) == "string","[text] is missing, or you just passed an empty data?")
|
||||
|
||||
assert(type(D.x) == "number" , "[x] must be a integer")
|
||||
assert(type(D.y) == "number" , "[y] must be a integer")
|
||||
assert(type(D.w) == "number" and D.w > 0, "[w] must be a positive integer")
|
||||
assert(type(D.h) == "number" and D.h > 0, "[h] must be a positive integer")
|
||||
assert((type(D.r) == "number" and D.r >= 0 and D.r <= D.w * 0.5 and D.r <= D.h * 0.5) or D.r == nil, "[r] must be a positive integer and cannot larger than half of button's width and half of button's height")
|
||||
else
|
||||
assert(type(D.r) == "number" and D.r >= 0 or D.r == nil, "[r] must be a positive integer (CAUTION: a extra condition is temproraily ignored because you are setting default option)")
|
||||
end
|
||||
assert(table.contains({"center","justify","left","right"}, D.textOrientation) or D.textOrientation == nil, "[borderJoin] must be 'bevel', 'miter' or 'none")
|
||||
|
||||
assert((type(D.r) == "number" and D.r >= 0 and D.r <= D.w * 0.5 and D.r <= D.h * 0.5) or D.r == nil, "[r] must be a positive integer and cannot larger than half of button's width and half of button's height")
|
||||
assert((type(D.borderWidth) == "number" and D.borderWidth > 0) or D.borderWidth == nil, "[borderWidth] must be a postive integer")
|
||||
assert(table.contains({"bevel", "miter", "none"}, D.borderJoin) or D.borderJoin == nil, "[borderJoin] must be 'bevel', 'miter' or 'none")
|
||||
assert(table.contains({"rough", "smooth"}, D.borderStyle) or D.borderStyle == nil, "[borderStyle] must be 'rough' or 'smooth'")
|
||||
|
||||
Reference in New Issue
Block a user