Skip to content

Instantly share code, notes, and snippets.

@exerro
Created February 8, 2017 22:58
Show Gist options
  • Save exerro/3006126061808510dfbc0fb75daaa55a to your computer and use it in GitHub Desktop.
Save exerro/3006126061808510dfbc0fb75daaa55a to your computer and use it in GitHub Desktop.
local app = sheets.Application()
local container = app.screen + sheets.Container( 0, 0, app.screen.width, app.screen.height )
local right = container + sheets.Button( "51 - self.width", 1, "#self.text + 4", 3, "Right" )
:set_ID "right"
local button1 = container + sheets.Button( 5, 0, "$$right.x - self.x", 5, "Hello world!" )
:set_ID "button1"
local centred = container + sheets.Button( "(parent.width - self.width) / 4 - 0.25", 12, 20, 5, "I am quarter x" )
local initial_anchor = container + sheets.Button( 20, 6, 20, 3, "!$.anchor == self & 'Initial anchor' | 'Non-anchor'" )
:add_tag "anchor"
:set_ID "initial_anchor"
local second_anchor = container + sheets.Button( 30, 10, 20, 3, "Second anchor" )
:add_tag "anchor"
local anchor_display = container + sheets.Button( "($.anchor).x", 14, 20, 3, "Anchor display" )
function initial_anchor:on_click()
if self:has_tag "anchor" then
self:remove_tag "anchor"
else
self:add_tag "anchor"
end
end
function button1:on_click()
self:animate_x( 20, 0.4 )
self.on_click = function()
app:stop()
end
end
function right:on_click()
self:animate_width( 15, 0.4 )
self.on_click = function()
self:set_text "!$$initial_anchor.text" -- the wrap_text() won't be necessary in any release
end
end
app:run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment