0
開關 - 當我「移動」開關時,widget.newSwitch()不起作用,它只在按下時才起作用。widget.newSwitch()開關在「移動」時不起作用
我已經嘗試設置「onEvent」,但看起來像它完全被忽略,沒有任何反應。
local widget = require("widget")
-- Handle press events for the checkbox
local function onSwitchPress(event)
local switch = event.target
print("Switch with ID '"..switch.id.."' is on: "..tostring(switch.isOn))
end
-- Create the widget
local onOffSwitch = widget.newSwitch
{
left = 250,
top = 200,
style = "onOff",
id = "onOffSwitch",
onPress = onSwitchPress
}
請您澄清一下在這種情況下「移動」是什麼意思? –
將切換器拖動到打開或關閉而不是按下。 – Orlo
請您在嘗試onEvent策略時顯示您使用的代碼,絕對需要查看。另外,是什麼讓你覺得你應該能夠滑動它?我從來沒有嘗試過,我也沒有在文檔中看到任何跡象表明這是可能的。 – Schollii