diff --git a/Basalt/Frame.lua b/Basalt/Frame.lua index 5ffaf3b..1b74faa 100644 --- a/Basalt/Frame.lua +++ b/Basalt/Frame.lua @@ -258,9 +258,9 @@ return function(name, parent, pTerm, basalt) setFocusedObject = function(self, obj) if(self.parent~=nil)then - --self:getBaseFrame():setFocusedObject(obj) + self.getBaseFrame():setFocusedObject(obj) else - --focusedObjectCache = obj + focusedObjectCache = obj end return self end; @@ -775,7 +775,7 @@ return function(name, parent, pTerm, basalt) if(isMonitor)and not(monitorAttached)then return false end; if (self:getVisualChanged()) then if (base.draw(self)) then - --[[if(self.parent==nil)then + if(self.parent==nil)then local curObj = basalt.getFocusedObject() basalt.setFocusedObject(focusedObjectCache) if(focusedObjectCache~=nil)then @@ -786,7 +786,7 @@ return function(name, parent, pTerm, basalt) curObj:loseFocusHandler() end end - end]] + end if(calculateDynValues)then _recalculateDynamicValues() end diff --git a/Basalt/Object.lua b/Basalt/Object.lua index 78f40d2..c32a6d2 100644 --- a/Basalt/Object.lua +++ b/Basalt/Object.lua @@ -681,7 +681,7 @@ return function(name) end if(event~="mouse_drag")then if (self.parent ~= nil)and(event~="mouse_up")then - self.parent:setFocusedObject(self) + --self.parent:setFocusedObject(self) elseif(self.parent == nil)and(event~="mouse_up")and(self:getType()=="Frame")then --self:setFocusedObject(self) end diff --git a/Basalt/libraries/logSystem.lua b/Basalt/libraries/logSystem.lua new file mode 100644 index 0000000..b954707 --- /dev/null +++ b/Basalt/libraries/logSystem.lua @@ -0,0 +1,16 @@ +local logDir = "" +local logFileName = "log.txt" + +return { + setLogDir = function(dir) + logDir = dir + end, + + setLogFileName = function(name) + logFileName = name + end, + + __call = function() + --somelogs + end +} \ No newline at end of file diff --git a/Basalt/libraries/utils.lua b/Basalt/libraries/utils.lua index 06c4657..5e9c973 100644 --- a/Basalt/libraries/utils.lua +++ b/Basalt/libraries/utils.lua @@ -1,3 +1,14 @@ +local splitString = function(str, sep) + if sep == nil then + sep = "%s" + end + local t={} + for v in string.gmatch(str, "([^"..sep.."]+)") do + table.insert(t, v) + end + return t +end + return { getTextHorizontalAlign = function(text, width, textAlign, replaceChar) text = string.sub(text, 1, width) @@ -37,15 +48,23 @@ rpairs = function(t) end, t, #t + 1 end, -splitString = function(str, sep) - if sep == nil then - sep = "%s" +splitString = splitString, + +createText = function(msg, maxWidth) + local words = splitString(msg, " ") + local lines = {} + local line = "" + for k,v in pairs(words)do + if(#line+#v <= maxWidth)then + line = line=="" and v or line.." "..v + if(k==#words)then table.insert(lines, line) end + else + table.insert(lines, line) + line = v:sub(1,maxWidth) + if(k==#words)then table.insert(lines, line) end + end end - local t={} - for v in string.gmatch(str, "([^"..sep.."]+)") do - table.insert(t, v) - end - return t + return lines end, getValueFromXML = function(name, tab) diff --git a/Basalt/objects/Label.lua b/Basalt/objects/Label.lua index b35527a..c730253 100644 --- a/Basalt/objects/Label.lua +++ b/Basalt/objects/Label.lua @@ -98,9 +98,10 @@ return function(name) local splittedText = utils.splitString(self:getValue(), " ") local text = {} local line = "" - for _,v in pairs(splittedText)do + for k,v in pairs(splittedText)do if(line:len()+v:len()<=w)then line = line=="" and v or line.." "..v + if(k==#splittedText)then table.insert(text, line) end else table.insert(text, line) line = v:sub(1,w) diff --git a/Basalt/objects/Textfield.lua b/Basalt/objects/Textfield.lua index a65e140..19dbc76 100644 --- a/Basalt/objects/Textfield.lua +++ b/Basalt/objects/Textfield.lua @@ -147,6 +147,14 @@ return function(name) return self end; + clear = function(self) + lines = {""} + bgLines = {""} + fgLines = {""} + hIndex, wIndex, textX, textY = 1, 1, 1, 1 + return self + end, + addLine = function(self, text, index) if(text~=nil)then if(#lines==1)and(lines[1]=="")then