Posted 30 June 2015 - 12:46 AM
Hey folks
i am having trouble auto aligning buttons, where the X is defined by 1,2,3,4, like this:
so in theory, i want the script to take the first button with X=1 and
set that as the first button, of course. the next button needs to be the X PLUS the width and a space.
This is the output of an automated X, with the preset of max 3 buttons per Y
Code:
This is the output of my stupid attempt at making it auto calculate FROM the x
So the question becomes, how to make it autoalign, with a preset WIDTH and HEIGHT, but a varying X and Y, which needs to be the parent to the WIDTH and HEIGTH.
Thanks in Advance
i am having trouble auto aligning buttons, where the X is defined by 1,2,3,4, like this:
{
Name = 'Button1',
Text = 'Button1',
Application = 'anywhere.app',
X = 1,
Y = 1,
},
{
Name = 'Button2',
Text = 'Button2',
Application = 'anywhere.app',
X = 2,
Y = 1,
},
Note, that the X and Y are not EXACT positions, which is the cause of my problem.so in theory, i want the script to take the first button with X=1 and
set that as the first button, of course. the next button needs to be the X PLUS the width and a space.
This is the output of an automated X, with the preset of max 3 buttons per Y
Spoiler
Code:
Spoiler
local Count = 0
local Width = 15
local Height = 3
for k, v in ipairs(Buttons) do
local X = 3 + (Count%3)*(Width+1)
local Y = 2 + (math.floor(Count/3)*(Height+1))
Count = Count + 1
-- use X and Y here to create a button.
api.createButton(X, Y, Width, Height, colors.gray)
end
This is the output of my stupid attempt at making it auto calculate FROM the x
Spoiler
Spoiler
local Count = 0
local Width = 15
local Height = 3
for k, v in ipairs(Buttons) do
local X = 3 + v.X * (Count%3)*Width
local Y = 2 + (math.floor(Count/3)*(Height+1))
Count = Count + 1
-- use X and Y here to create a button.
api.createButton(X, Y, Width, Height, colors.gray)
end
So the question becomes, how to make it autoalign, with a preset WIDTH and HEIGHT, but a varying X and Y, which needs to be the parent to the WIDTH and HEIGTH.
Thanks in Advance
Edited on 29 June 2015 - 10:46 PM