mirror of
https://github.com/kepler155c/opus
synced 2025-01-11 16:20:26 +00:00
dialogs
This commit is contained in:
parent
72bd16502b
commit
6754eb98d3
@ -86,7 +86,15 @@ function methodsPage:enable(p)
|
||||
self.peripheral = p or self.peripheral
|
||||
|
||||
local p = peripheral.wrap(self.peripheral.side)
|
||||
if not p.getAdvancedMethodsData then
|
||||
if p.getDocs then
|
||||
self.grid.values = { }
|
||||
for k,v in pairs(p.getDocs()) do
|
||||
table.insert(self.grid.values, {
|
||||
name = k,
|
||||
doc = v,
|
||||
})
|
||||
end
|
||||
elseif not p.getAdvancedMethodsData then
|
||||
self.grid.values = { }
|
||||
for name,f in pairs(p) do
|
||||
table.insert(self.grid.values, {
|
||||
@ -134,6 +142,12 @@ function methodsPage.viewportConsole:draw()
|
||||
return 2
|
||||
end
|
||||
|
||||
if method.doc then
|
||||
c:print(method.doc, nil, colors.yellow)
|
||||
c.ymax = c.cursorY + 1
|
||||
return
|
||||
end
|
||||
|
||||
if method.description then
|
||||
c:print(method.description)
|
||||
end
|
||||
|
@ -338,28 +338,32 @@ end
|
||||
|
||||
local function nameDialog(f)
|
||||
local dialog = UI.Dialog({
|
||||
x = (UI.term.width - 28) / 2,
|
||||
width = 28,
|
||||
textEntry = UI.TextEntry({ x = 4, y = 3, width = 20, limit = 20 })
|
||||
-- x = (UI.term.width - 28) / 2,
|
||||
width = 22,
|
||||
title = 'Enter Name',
|
||||
form = UI.Form {
|
||||
x = 2, rex = -2, y = 2,
|
||||
textEntry = UI.TextEntry({ y = 3, width = 20, limit = 20 })
|
||||
},
|
||||
})
|
||||
|
||||
dialog.titleBar.title = 'Enter Name'
|
||||
|
||||
dialog.eventHandler = function(self, event)
|
||||
if event.type == 'accept' then
|
||||
local name = self.textEntry.value
|
||||
if event.type == 'form_complete' then
|
||||
local name = self.form.textEntry.value
|
||||
if name then
|
||||
f(name)
|
||||
else
|
||||
self.statusBar:timedStatus('Invalid Name', 3)
|
||||
end
|
||||
return true
|
||||
elseif event.type == 'form_cancel' or event.type == 'cancel' then
|
||||
UI:setPreviousPage()
|
||||
else
|
||||
return UI.Dialog.eventHandler(self, event)
|
||||
end
|
||||
|
||||
return UI.Dialog.eventHandler(self, event)
|
||||
end
|
||||
|
||||
dialog:setFocus(dialog.textEntry)
|
||||
dialog:setFocus(dialog.form.textEntry)
|
||||
UI:setPage(dialog)
|
||||
end
|
||||
|
||||
|
@ -3164,10 +3164,10 @@ UI.Dialog.defaults = {
|
||||
function UI.Dialog:init(args)
|
||||
local defaults = UI:getDefaults(UI.Dialog, args)
|
||||
|
||||
UI.setProperties(defaults, {
|
||||
width = UI.term.width-11,
|
||||
titleBar = UI.TitleBar({ previousPage = true, title = defaults.title }),
|
||||
})
|
||||
if not defaults.width then
|
||||
defaults.width = UI.term.width-11
|
||||
end
|
||||
defaults.titleBar = UI.TitleBar({ previousPage = true, title = defaults.title })
|
||||
|
||||
--UI.setProperties(defaults, args)
|
||||
UI.Page.init(self, defaults)
|
||||
|
Loading…
Reference in New Issue
Block a user