Created
February 11, 2017 18:10
-
-
Save exerro/b73ffe9825e13aa3f33c163604ece904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
:set_width_transition( sheets.Transition.smooth ) | |
local button1 = container + sheets.Button( 5, 0, "$$right.x - self.x", 5, "Hello world!" ) | |
:set_ID "button1" | |
:set_x_transition( sheets.Transition.smooth ) | |
local centred = container + sheets.Button( "(parent.width - self.width) / 4 - 0.75", 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" ) | |
:set_x_transition( sheets.Transition.smooth_fast ) | |
function initial_anchor:on_click() | |
if self:has_tag "anchor" then | |
self:remove_tag "anchor" | |
else | |
self:add_tag "anchor" | |
end | |
end | |
function second_anchor:on_click() | |
button1:set_parent( not button1.parent and container or nil ) | |
end | |
function button1:on_click() | |
self:set_x( 20 ) | |
self.on_click = function() app:stop() end | |
end | |
function right:on_click() | |
self:set_width( 15 ) | |
self.on_click = function() self:set_text "!$$initial_anchor.text" end | |
end | |
app:run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment