mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
some rework in UIWidget input
This commit is contained in:
@@ -22,13 +22,14 @@ MainWindow
|
||||
margin-bottom: 5
|
||||
padding: 1
|
||||
focusable: false
|
||||
vertical-scrollbar: characterListScrollBar
|
||||
|
||||
VerticalScrollBar
|
||||
attached-to: characterList
|
||||
id: characterListScrollBar
|
||||
anchors.top: characterList.top
|
||||
anchors.bottom: characterList.bottom
|
||||
anchors.right: characterList.right
|
||||
maximum: 0
|
||||
step: 14
|
||||
|
||||
Label
|
||||
id: accountStatusLabel
|
||||
|
@@ -17,7 +17,7 @@ function Mouse.restoreCursor()
|
||||
end
|
||||
|
||||
function Mouse.isPressed()
|
||||
return g_ui.getPressedWidget() == nil
|
||||
return g_ui.getPressedWidget() ~= nil
|
||||
end
|
||||
|
||||
function Mouse.bindAutoPress(widget, callback)
|
||||
|
@@ -33,7 +33,9 @@ function UIScrollArea:updateScrollBars()
|
||||
if scrollbar then
|
||||
if self.inverted then
|
||||
scrollbar:setMinimum(-scrollheight)
|
||||
scrollbar:setMaximum(0)
|
||||
else
|
||||
scrollbar:setMinimum(0)
|
||||
scrollbar:setMaximum(scrollheight)
|
||||
end
|
||||
end
|
||||
@@ -50,10 +52,8 @@ end
|
||||
|
||||
function UIScrollArea:setVerticalScrollBar(scrollbar)
|
||||
self.verticalScrollBar = scrollbar
|
||||
scrollbar:setMaximum(0)
|
||||
self.verticalScrollBar.onValueChange = function(scrollbar, value)
|
||||
local virtualOffset = self:getVirtualOffset()
|
||||
if self.inverted then value = -value end
|
||||
virtualOffset.y = value
|
||||
self:setVirtualOffset(virtualOffset)
|
||||
end
|
||||
@@ -72,3 +72,14 @@ end
|
||||
function UIScrollArea:onLayoutUpdate()
|
||||
self:updateScrollBars()
|
||||
end
|
||||
|
||||
function UIScrollArea:onMouseWheel(mousePos, mouseWheel)
|
||||
if self.verticalScrollBar then
|
||||
if mouseWheel == MouseWheelUp then
|
||||
self.verticalScrollBar:decrement()
|
||||
else
|
||||
self.verticalScrollBar:increment()
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@@ -22,7 +22,7 @@ local function calcValues(self)
|
||||
local px = math.max(math.floor(proportion * pxrange), 10)
|
||||
local offset = 0
|
||||
if range > 1 then
|
||||
offset = (((self.value - self.minimum) / (range - 1)) - 0.5) * (pxrange - px)
|
||||
offset = math.ceil((((self.value - self.minimum) / (range - 1)) - 0.5) * (pxrange - px))
|
||||
end
|
||||
|
||||
return range, pxrange, px, offset, center
|
||||
@@ -153,6 +153,15 @@ function UIScrollBar:onGeometryChange()
|
||||
updateSlider(self)
|
||||
end
|
||||
|
||||
function UIScrollBar:onMouseWheel(mousePos, mouseWheel)
|
||||
if mouseWheel == MouseWheelUp then
|
||||
self:decrement()
|
||||
else
|
||||
self:increment()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function UIScrollBar:getMaximum() return self.maximum end
|
||||
function UIScrollBar:getMinimum() return self.minimum end
|
||||
function UIScrollBar:getValue() return self.value end
|
||||
|
@@ -46,7 +46,6 @@ function UISplitter:onMouseRelease(mousePos, mouseButton)
|
||||
if not self:isHovered() then
|
||||
Mouse.restoreCursor()
|
||||
end
|
||||
self:ungrabMouse()
|
||||
end
|
||||
|
||||
function UISplitter:onStyleApply(styleName, styleNode)
|
||||
|
@@ -215,10 +215,6 @@ function Console.terminate()
|
||||
Console = nil
|
||||
end
|
||||
|
||||
function Console.debug()
|
||||
print(#channels)
|
||||
end
|
||||
|
||||
function Console.clear()
|
||||
for channelid, channelname in pairs(channels) do
|
||||
if channelid ~= 0 then
|
||||
|
@@ -12,7 +12,6 @@ ConsoleTabBarPanel < TabBarPanel
|
||||
|
||||
ScrollablePanel
|
||||
id: consoleBuffer
|
||||
// height = max lines * 14
|
||||
anchors.fill: parent
|
||||
margin-right: 12
|
||||
vertical-scrollbar: consoleScrollBar
|
||||
|
Reference in New Issue
Block a user