-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParagraphScreen.brs
71 lines (56 loc) · 1.69 KB
/
ParagraphScreen.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
'*
'* A very simple wrapper around a paragraph screen.
'*
'** Credit: Plex Roku https://github.com/plexinc/roku-client-public
Function createParagraphScreen(header, paragraphs, viewController)
obj = CreateObject("roAssociativeArray")
initBaseScreen(obj, viewController)
obj.Show = paragraphShow
screen = CreateObject("roParagraphScreen")
screen.SetMessagePort(obj.Port)
screen.AddHeaderText(header)
for each paragraph in paragraphs
screen.AddParagraph(paragraph)
next
' Allow callers to add buttons just like on our dialogs
obj.SetButton = dialogSetButton
obj.Buttons = []
obj.HandleButton = invalid
obj.Screen = screen
obj.HandleMessage = paragraphHandleMessage
return obj
End Function
Function paragraphShow()
' If the caller didn't add any buttons, add a simple close button
if m.Buttons.Count() = 0 then
m.Buttons.Push({close: "close"})
end if
buttonCount = 0
m.ButtonCommands = []
for each button in m.Buttons
button.Reset()
cmd = button.Next()
m.ButtonCommands[buttonCount] = cmd
m.Screen.AddButton(buttonCount, button[cmd])
buttonCount = buttonCount + 1
next
m.Screen.Show()
End Function
Function paragraphHandleMessage(msg) As Boolean
handled = false
if type(msg) = "roParagraphScreenEvent" then
handled = true
if msg.isScreenClosed() then
m.ViewController.PopScreen(m)
else if msg.isButtonPressed() then
command = m.ButtonCommands[msg.GetIndex()]
Debug("Button pressed: " + tostr(command))
done = true
if m.HandleButton <> invalid then
done = m.HandleButton(command, msg.GetData())
end if
if done then m.Screen.Close()
end if
end if
return handled
End Function