core/menusystem: make cursor position relative to first element

This commit is contained in:
Kazhnuz 2019-02-13 17:51:05 +01:00
parent f2b520e2b3
commit 0a4d57e46b
2 changed files with 3 additions and 2 deletions

View file

@ -167,11 +167,12 @@ function FlowBox:draw()
end
function FlowBox:drawCursor()
local begincol, beginline = self:getCoord(self.view.firstSlot)
if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) then
local w, h = self:getWidgetSize()
local col, line = self:getCoord(self.widget.selected)
local x = (col) * h
local y = (line) * h
local y = (line - beginline) * h
menuutils.drawCursor(self.x + x, self.y + y, w, h)
end
end

View file

@ -90,7 +90,7 @@ end
function ListBox:drawCursor()
if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) then
local w, h = self:getWidgetSize()
local y = (self.widget.selected - 1) * h
local y = (self.widget.selected - self.view.firstSlot) * h
menuutils.drawCursor(self.x,self.y + y, w, h)
end
end