Fixes
- fixed a bug where program still listens to other events (even the program is using a filter for pullEvent) - fixed a focus bug, now if a program is focused and you terminate, the program will be terminated instead of basalt)
This commit is contained in:
@@ -38,7 +38,7 @@ return function(name, parent, pTerm, basalt)
|
||||
local isMovable = false
|
||||
local isDragging =false
|
||||
|
||||
local focusedOBjectCache
|
||||
local focusedObjectCache
|
||||
local focusedObject
|
||||
local autoSize = true
|
||||
local autoScroll = true
|
||||
@@ -339,14 +339,15 @@ return function(name, parent, pTerm, basalt)
|
||||
end
|
||||
|
||||
local function focusSystem(self)
|
||||
if(focusedObject~=focusedOBjectCache)then
|
||||
if(focusedObject~=focusedObjectCache)then
|
||||
if(focusedObject~=nil)then
|
||||
focusedObject:loseFocusHandler()
|
||||
end
|
||||
if(focusedOBjectCache~=nil)then
|
||||
focusedOBjectCache:getFocusHandler()
|
||||
if(focusedObjectCache~=nil)then
|
||||
focusedObjectCache:getFocusHandler()
|
||||
end
|
||||
focusedObject = focusedOBjectCache
|
||||
focusedObject = focusedObjectCache
|
||||
focusedObjectCache = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -371,7 +372,7 @@ return function(name, parent, pTerm, basalt)
|
||||
end;
|
||||
|
||||
setFocusedObject = function(self, obj)
|
||||
focusedOBjectCache = obj
|
||||
focusedObjectCache = obj
|
||||
return self
|
||||
end;
|
||||
|
||||
@@ -447,7 +448,7 @@ return function(name, parent, pTerm, basalt)
|
||||
end;
|
||||
|
||||
removeFocusedObject = function(self)
|
||||
focusedOBjectCache = nil
|
||||
focusedObjectCache = nil
|
||||
return self
|
||||
end;
|
||||
|
||||
@@ -667,7 +668,7 @@ return function(name, parent, pTerm, basalt)
|
||||
|
||||
loseFocusHandler = function(self)
|
||||
base.loseFocusHandler(self)
|
||||
if(focusedObject~=nil)then focusedObject:loseFocusHandler() end
|
||||
if(focusedObject~=nil)then focusedObject:loseFocusHandler() focusedObject = nil end
|
||||
end;
|
||||
|
||||
getFocusHandler = function(self)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
local basaltEvent = require("basaltEvent")
|
||||
local utils = require("utils")
|
||||
local log = require("basaltLogs")
|
||||
local split = utils.splitString
|
||||
local numberFromString = utils.numberFromString
|
||||
local xmlValue = utils.getValueFromXML
|
||||
@@ -828,6 +829,7 @@ return function(name)
|
||||
getFocusHandler = function(self)
|
||||
local val = eventSystem:sendEvent("get_focus", self)
|
||||
if(val~=nil)then return val end
|
||||
log("Focus "..self:getName())
|
||||
return true
|
||||
end;
|
||||
|
||||
@@ -835,6 +837,7 @@ return function(name)
|
||||
isDragging = false
|
||||
local val = eventSystem:sendEvent("lose_focus", self)
|
||||
if(val~=nil)then return val end
|
||||
log("Losefocus "..self:getName())
|
||||
return true
|
||||
end;
|
||||
|
||||
|
||||
@@ -17,12 +17,16 @@ end
|
||||
|
||||
function process:resume(event, ...)
|
||||
term.redirect(self.window)
|
||||
if(self.filter~=nil)then
|
||||
if(event~=self.filter)then return end
|
||||
self.filter=nil
|
||||
end
|
||||
local ok, result = coroutine.resume(self.coroutine, event, ...)
|
||||
self.window = term.current()
|
||||
if ok then
|
||||
self.filter = result
|
||||
else
|
||||
basalt.debug(result)
|
||||
error(result)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ local basaltEvent = require("basaltEvent")()
|
||||
local Frame = require("Frame")
|
||||
local theme = require("theme")
|
||||
local utils = require("utils")
|
||||
local log = require("basaltLogs")
|
||||
local uuid = utils.uuid
|
||||
local createText = utils.createText
|
||||
|
||||
|
||||
@@ -675,7 +675,7 @@ return function(name, parent)
|
||||
end
|
||||
end
|
||||
end
|
||||
end;
|
||||
end,
|
||||
|
||||
loseFocusHandler = function(self)
|
||||
base.loseFocusHandler(self)
|
||||
@@ -686,7 +686,7 @@ return function(name, parent)
|
||||
end
|
||||
end
|
||||
end
|
||||
end;
|
||||
end,
|
||||
|
||||
eventHandler = function(self, event, p1, p2, p3, p4)
|
||||
if(base.eventHandler(self, event, p1, p2, p3, p4))then
|
||||
@@ -721,6 +721,7 @@ return function(name, parent)
|
||||
end
|
||||
|
||||
if (event == "terminate") then
|
||||
log(self:isFocused())
|
||||
curProcess:resume(event)
|
||||
self.parent:setCursor(false)
|
||||
return true
|
||||
@@ -730,8 +731,9 @@ return function(name, parent)
|
||||
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
end;
|
||||
end,
|
||||
|
||||
draw = function(self)
|
||||
if (base.draw(self)) then
|
||||
@@ -739,9 +741,6 @@ return function(name, parent)
|
||||
local obx, oby = self:getAnchorPosition()
|
||||
local w,h = self:getSize()
|
||||
pWindow.basalt_reposition(obx, oby)
|
||||
if(self.bgColor~=false)then
|
||||
self.parent:drawBackgroundBox(obx, oby, w, h, self.bgColor)
|
||||
end
|
||||
pWindow.basalt_update()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user