mirror of
https://github.com/airstruck/luigi.git
synced 2025-11-18 12:25:06 +00:00
Widget.pressed is now a table of booleans keyed by mouse button name
This commit is contained in:
@@ -12,7 +12,7 @@ return {
|
|||||||
width = 48,
|
width = 48,
|
||||||
height = 48,
|
height = 48,
|
||||||
slices = function (self)
|
slices = function (self)
|
||||||
if self.focused or self.hovered or self.pressed then
|
if self.focused or self.hovered or self.pressed.left then
|
||||||
return nil -- fall back to theme default
|
return nil -- fall back to theme default
|
||||||
end
|
end
|
||||||
return false -- no slices
|
return false -- no slices
|
||||||
|
|||||||
@@ -129,9 +129,7 @@ function Input:handlePressedMove (layout, x, y)
|
|||||||
x = x, y = y
|
x = x, y = y
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
if button == 'left' then
|
originWidget.pressed[button] = (widget == originWidget) or nil
|
||||||
originWidget.pressed = (widget == originWidget) or nil
|
|
||||||
end
|
|
||||||
if passedWidget then
|
if passedWidget then
|
||||||
passedWidget:bubbleEvent('PressLeave', {
|
passedWidget:bubbleEvent('PressLeave', {
|
||||||
hit = hit,
|
hit = hit,
|
||||||
@@ -165,8 +163,8 @@ function Input:handlePressStart (layout, button, x, y, widget, accelerator)
|
|||||||
if hit then
|
if hit then
|
||||||
self.pressedWidgets[button] = widget
|
self.pressedWidgets[button] = widget
|
||||||
self.passedWidgets[button] = widget
|
self.passedWidgets[button] = widget
|
||||||
|
widget.pressed[button] = true
|
||||||
if button == 'left' then
|
if button == 'left' then
|
||||||
widget.pressed = true
|
|
||||||
widget:focus()
|
widget:focus()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -188,8 +186,8 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
|
|||||||
end
|
end
|
||||||
local originWidget = self.pressedWidgets[button]
|
local originWidget = self.pressedWidgets[button]
|
||||||
if not originWidget then return end
|
if not originWidget then return end
|
||||||
if hit and button == 'left' then
|
if hit then
|
||||||
originWidget.pressed = nil
|
originWidget.pressed[button] = nil
|
||||||
end
|
end
|
||||||
widget:bubbleEvent('PressEnd', {
|
widget:bubbleEvent('PressEnd', {
|
||||||
hit = hit,
|
hit = hit,
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ return function (config)
|
|||||||
local text = resources .. 'text.png'
|
local text = resources .. 'text.png'
|
||||||
|
|
||||||
local function getButtonSlices (self)
|
local function getButtonSlices (self)
|
||||||
return self.pressed and button_pressed
|
return self.pressed.left and button_pressed
|
||||||
or self.focused and button_focused
|
or self.focused and button_focused
|
||||||
or self.hovered and button_hovered
|
or self.hovered and button_hovered
|
||||||
or button
|
or button
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getCheckIcon (self)
|
local function getCheckIcon (self)
|
||||||
if self.pressed then
|
if self.pressed.left then
|
||||||
return self.value and check_checked_pressed
|
return self.value and check_checked_pressed
|
||||||
or check_unchecked_pressed
|
or check_unchecked_pressed
|
||||||
end
|
end
|
||||||
@@ -67,7 +67,7 @@ return function (config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getRadioIcon (self)
|
local function getRadioIcon (self)
|
||||||
if self.pressed then
|
if self.pressed.left then
|
||||||
return self.value and radio_checked_pressed
|
return self.value and radio_checked_pressed
|
||||||
or radio_unchecked_pressed
|
or radio_unchecked_pressed
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Whether the pointer was pressed on this widget and not yet released.
|
|||||||
Can be used by styles and themes. This value is automatically set by
|
Can be used by styles and themes. This value is automatically set by
|
||||||
the `Input` class, and should generally be treated as read-only.
|
the `Input` class, and should generally be treated as read-only.
|
||||||
--]]--
|
--]]--
|
||||||
Widget.pressed = false
|
Widget.pressed = nil
|
||||||
|
|
||||||
--[[--
|
--[[--
|
||||||
Internal Properties
|
Internal Properties
|
||||||
@@ -88,12 +88,12 @@ Widget.hasType = false
|
|||||||
--[[--
|
--[[--
|
||||||
The `Font` object associated with the widget.
|
The `Font` object associated with the widget.
|
||||||
--]]--
|
--]]--
|
||||||
Widget.fontData = false
|
Widget.fontData = nil
|
||||||
|
|
||||||
--[[--
|
--[[--
|
||||||
The `Text` object associated with the widget.
|
The `Text` object associated with the widget.
|
||||||
--]]--
|
--]]--
|
||||||
Widget.textData = false
|
Widget.textData = nil
|
||||||
|
|
||||||
|
|
||||||
--[[--
|
--[[--
|
||||||
@@ -216,6 +216,7 @@ local function metaCall (Widget, layout, self)
|
|||||||
self.dimensions = { width = nil, height = nil }
|
self.dimensions = { width = nil, height = nil }
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
self.attributeDescriptors = {}
|
self.attributeDescriptors = {}
|
||||||
|
self.pressed = {}
|
||||||
self.painter = Painter(self)
|
self.painter = Painter(self)
|
||||||
|
|
||||||
setmetatable(self, { __index = metaIndex, __newindex = metaNewIndex })
|
setmetatable(self, { __index = metaIndex, __newindex = metaNewIndex })
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return function (self)
|
|||||||
|
|
||||||
local function unpress (event)
|
local function unpress (event)
|
||||||
if event.button ~= 'left' then return end
|
if event.button ~= 'left' then return end
|
||||||
thumb.pressed = false -- don't make the thumb appear pushed in
|
thumb.pressed.left = nil -- don't make the thumb appear pushed in
|
||||||
return false -- don't press thumb on focused keyboard activation
|
return false -- don't press thumb on focused keyboard activation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user