mirror of
https://github.com/kepler155c/opus
synced 2025-10-27 21:57:40 +00:00
properly handle empty text entry fields (including transformations)
This commit is contained in:
@@ -81,7 +81,7 @@ function page:eventHandler(event)
|
||||
end
|
||||
|
||||
elseif event.type == 'text_change' then
|
||||
if #event.text == 0 then
|
||||
if not event.text then
|
||||
self.grid.values = topics
|
||||
else
|
||||
self.grid.values = { }
|
||||
|
||||
@@ -153,10 +153,11 @@ function page:eventHandler(event)
|
||||
self.tabs:selectTab(self.tabs[2])
|
||||
|
||||
elseif event.type == 'autocomplete' then
|
||||
local sz = #self.prompt.value
|
||||
local value = self.prompt.value or ''
|
||||
local sz = #value
|
||||
local pos = self.prompt.entry.pos
|
||||
self:setPrompt(autocomplete(sandboxEnv, self.prompt.value, self.prompt.entry.pos))
|
||||
self.prompt:setPosition(pos + #self.prompt.value - sz)
|
||||
self:setPrompt(autocomplete(sandboxEnv, value, self.prompt.entry.pos))
|
||||
self.prompt:setPosition(pos + #value - sz)
|
||||
self.prompt:updateCursor()
|
||||
|
||||
elseif event.type == 'device' then
|
||||
@@ -177,7 +178,7 @@ function page:eventHandler(event)
|
||||
history:reset()
|
||||
|
||||
elseif event.type == 'command_enter' then
|
||||
local s = tostring(self.prompt.value)
|
||||
local s = tostring(self.prompt.value or '')
|
||||
|
||||
if #s > 0 then
|
||||
self:executeStatement(s)
|
||||
|
||||
@@ -120,7 +120,9 @@ local page = UI.Page {
|
||||
}
|
||||
|
||||
function page.wizard.pages.label:validate()
|
||||
os.setComputerLabel(self.label.value)
|
||||
if self.label.value then
|
||||
os.setComputerLabel(self.label.value)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -6,11 +6,6 @@ local multishell = _ENV.multishell
|
||||
local name = ({ ... })[1] or error('Syntax: inspect COMPONENT')
|
||||
local events = { }
|
||||
local page
|
||||
local component = UI[name] and UI[name]() or error('Invalid component')
|
||||
|
||||
if not component.example then
|
||||
error('No example present')
|
||||
end
|
||||
|
||||
local function isRelevant(el)
|
||||
return page.testContainer == el or el.parent and isRelevant(el.parent)
|
||||
@@ -18,8 +13,7 @@ end
|
||||
|
||||
local emitter = UI.Window.emit
|
||||
function UI.Window:emit(event)
|
||||
if not event.recorded and isRelevant(self) then
|
||||
event.recorded = true
|
||||
if not event._recorded and isRelevant(self) then
|
||||
local t = { }
|
||||
for k,v in pairs(event) do
|
||||
if k ~= 'type' and k ~= 'recorded' then
|
||||
@@ -35,9 +29,16 @@ function UI.Window:emit(event)
|
||||
page.tabs.events.grid:draw()
|
||||
end
|
||||
end
|
||||
event._recorded = true
|
||||
return emitter(self, event)
|
||||
end
|
||||
|
||||
-- do not load component until emit hook is in place
|
||||
local component = UI[name] and UI[name]() or error('Invalid component')
|
||||
if not component.example then
|
||||
error('No example present')
|
||||
end
|
||||
|
||||
page = UI.Page {
|
||||
testContainer = UI.Window {
|
||||
ey = 10,
|
||||
@@ -122,7 +123,7 @@ page = UI.Page {
|
||||
self.tabs.methodsTab.grid:draw()
|
||||
|
||||
elseif event.type == 'grid_select' and event.element == self.tabs.events.grid then
|
||||
event.selected.raw.recorded = nil
|
||||
event.selected.raw._recorded = nil
|
||||
multishell.openTab({
|
||||
path = 'sys/apps/Lua.lua',
|
||||
args = { event.selected.raw },
|
||||
|
||||
@@ -39,7 +39,7 @@ local labelTab = UI.Tab {
|
||||
}
|
||||
|
||||
function labelTab:eventHandler(event)
|
||||
if event.type == 'update_label' then
|
||||
if event.type == 'update_label' and self.label.value then
|
||||
os.setComputerLabel(self.label.value)
|
||||
self:emit({ type = 'success_message', message = 'Label updated' })
|
||||
return true
|
||||
|
||||
@@ -59,7 +59,7 @@ function tab:save()
|
||||
end
|
||||
|
||||
function tab:eventHandler(event)
|
||||
if event.type == 'update_path' then
|
||||
if event.type == 'update_path' and self.entry.value then
|
||||
table.insert(self.grid.values, {
|
||||
value = self.entry.value,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user