-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.lua
More file actions
61 lines (56 loc) · 1.4 KB
/
main.lua
File metadata and controls
61 lines (56 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
display.setDefault('background', 1, 0 , 0 )
local widget = require('widget')
local dropdown = require('dropdown')
local screen = require('screen')
local myDropdown
local dropdownOptions = {
{
title = 'Go to Home',
action = function()
native.showAlert('Dropdown', 'Dropdown', {'Ok'})
end
},
{
rightIcon = display.newImageRect('rightIcon.png', 32, 32),
title = 'Test',
action = function()
native.showAlert('Dropdown', 'Dropdown', {'Ok'})
end
},
{
leftIcon = display.newImageRect('star.png', 32, 32),
rightIcon = display.newImageRect('rightIcon.png', 32, 32),
title = 'My favorite component',
action = function()
native.showAlert('Dropdown', 'Dropdown', {'Ok'})
end
},
}
local button = widget.newButton{
width = 32,
height = 32,
defaultFile = 'arrow.png',
overFile = 'arrow.png',
onEvent = function( event )
local target = event.target
local phase = event.phase
if phase == 'began' then
target.alpha = .5
else
target.alpha = 1
if phase == 'ended' then
myDropdown:toggle()
end
end
end
}
button.alpha = .5
myDropdown = dropdown.new{
x = screen.rightSide - 20,
y = screen.topSide + 100,
toggleButton = button,
width = 280,
marginTop = 12,
padding = 20,
options = dropdownOptions
}