跳到主要内容

setRequired()

选择 OK 是否等待此问题的答案。该方法适用于 NumberInput、Slider、TapPicker、TapListPicker 和 GestureRecorder。

签名​

setRequired(required: boolean): DialogComponent

返回值

同一个问题,因此可以链式调用

哪些问题是必填的​

问题除非您更改,否则为必填
NumberInput是
TapPicker、GestureRecorder是,前提是没有默认值
TapListPicker是
Slider始终有答案

示例​

-- Optional: the macro uses its own search when the user skips it
Dialog:add(TapPicker(1, "Tap the Search button"):setRequired(false))
Dialog:show()
local search = Dialog:getValueById(1)
if search ~= nil then
Screen:click(search, ClickParams())
end