mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
scroll when focusing widgets
This commit is contained in:
@@ -26,8 +26,8 @@ end
|
||||
|
||||
function UIScrollArea:updateScrollBars()
|
||||
local offset = { x = 0, y = 0 }
|
||||
local scrollheight = math.max(self:getChildrenRect().height - self:getClippingRect().height, 0)
|
||||
local scrollwidth = math.max(self:getChildrenRect().width - self:getClippingRect().width, 0)
|
||||
local scrollheight = math.max(self:getChildrenRect().height - self:getPaddingRect().height, 0)
|
||||
local scrollwidth = math.max(self:getChildrenRect().width - self:getPaddingRect().width, 0)
|
||||
|
||||
local scrollbar = self.verticalScrollBar
|
||||
if scrollbar then
|
||||
@@ -83,3 +83,18 @@ function UIScrollArea:onMouseWheel(mousePos, mouseWheel)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function UIScrollArea:onChildFocusChange(focusedChild, oldFocused, reason)
|
||||
if focusedChild and (reason == MouseFocusReason or reason == KeyboardFocusReason) then
|
||||
local paddingRect = self:getPaddingRect()
|
||||
local delta = paddingRect.y - focusedChild:getY()
|
||||
if delta > 0 then
|
||||
self.verticalScrollBar:decrement(delta)
|
||||
end
|
||||
|
||||
delta = (focusedChild:getY() + focusedChild:getHeight()) - (paddingRect.y + paddingRect.height)
|
||||
if delta > 0 then
|
||||
self.verticalScrollBar:increment(delta)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -126,11 +126,13 @@ function UIScrollBar:onStyleApply(styleName, styleNode)
|
||||
end
|
||||
end
|
||||
|
||||
function UIScrollBar:decrement()
|
||||
function UIScrollBar:decrement(count)
|
||||
count = count or self.step
|
||||
self:setValue(self.value - self.step)
|
||||
end
|
||||
|
||||
function UIScrollBar:increment()
|
||||
function UIScrollBar:increment(count)
|
||||
count = count or self.step
|
||||
self:setValue(self.value + self.step)
|
||||
end
|
||||
|
||||
|
@@ -35,10 +35,10 @@ local function onGameQuestLine(questId, questMissions)
|
||||
local missionList = questLineWindow:getChildById('missionList')
|
||||
local missionDescription = questLineWindow:getChildById('missionDescription')
|
||||
|
||||
missionList.onChildFocusChange = function(self, focusedChild)
|
||||
connect(missionList, { onChildFocusChange = function(self, focusedChild)
|
||||
if focusedChild == nil then return end
|
||||
missionDescription:setText(focusedChild.description)
|
||||
end
|
||||
end })
|
||||
|
||||
for i,questMission in pairs(questMissions) do
|
||||
local name, description = unpack(questMission)
|
||||
|
Reference in New Issue
Block a user