This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
forked from ncalexan/firefox-roku
/
dialogs.brs
79 lines (67 loc) · 2.15 KB
/
dialogs.brs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
' This Source Code Form is subject to the terms of the Mozilla Public
' License, v. 2.0. If a copy of the MPL was not distributed with this file,
' You can obtain one at http://mozilla.org/MPL/2.0/.
function showMessage(title As dynamic, message As dynamic, buttons=invalid as dynamic) As object
port = createObject("roMessagePort")
dialog = createObject("roMessageDialog")
dialog.setMessagePort(port)
dialog.setTitle(title)
dialog.setText(message)
if buttons = invalid then
dialog.addButton(0, "Back")
dialog.enableBackButton(true)
else
index = 0
for each button in buttons
dialog.addButton(index, button)
index = index + 1
next
end if
dialog.show()
while true
dlgMsg = wait(0, dialog.getMessagePort())
if type(dlgMsg) = "roMessageDialogEvent"
if dlgMsg.isScreenClosed()
dialog = invalid
return 0
else if dlgMsg.isButtonPressed()
dialog = invalid
return dlgMsg.getIndex()
endif
endif
end while
end function
function showPopup(title As dynamic, buttons As dynamic) As object
port = createObject("roMessagePort")
dialog = createObject("roMessageDialog")
dialog.setMessagePort(port)
dialog.setMenuTopLeft(true)
dialog.enableBackButton(true)
dialog.enableOverlay(true)
dialog.setTitle(title)
index = 0
for each button in buttons
if button = "-" then
dialog.addButtonSeparator()
else
dialog.addButton(index, button)
index = index + 1
end if
next
dialog.show()
while true
dlgMsg = wait(0, dialog.getMessagePort())
if type(dlgMsg) = "roMessageDialogEvent"
if dlgMsg.isScreenClosed()
dialog = invalid
return -1
else if dlgMsg.isButtonPressed()
dialog = invalid
return dlgMsg.getIndex()
else if dlgMsg.isButtonInfo() then
dialog = invalid
return -1
endif
endif
end while
end function