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