Drop test if *_func is a function

This commit is contained in:
zwim
2025-07-30 07:53:29 +02:00
parent 42e2535477
commit 201a1f035c
4 changed files with 7 additions and 7 deletions

View File

@@ -1593,7 +1593,7 @@ function ReaderLink:getButtonsForExternalLinkDialog(link_url)
local button = fn_button(self, link_url)
local show, button_title
if type(button.show_in_dialog_func) == "function" then
if button.show_in_dialog_func then
show, button_title = button.show_in_dialog_func(link_url)
else
-- If the button doesn't have the show_in_dialog_func, then assume that the button

View File

@@ -80,7 +80,7 @@ function Button:init()
end
-- Prefer an optional text_func over text
if self.text_func and type(self.text_func) == "function" then
if self.text_func then
self.text = self.text_func()
end
@@ -507,7 +507,7 @@ function Button:onTapSelectButton()
end
elseif self.tap_input then
self:onInput(self.tap_input)
elseif type(self.tap_input_func) == "function" then
elseif self.tap_input_func then
self:onInput(self.tap_input_func())
end
end
@@ -546,7 +546,7 @@ function Button:onHoldSelectButton()
elseif self.hold_input then
self:onInput(self.hold_input, true)
self._hold_handled = true
elseif type(self.hold_input_func) == "function" then
elseif self.hold_input_func then
self:onInput(self.hold_input_func(), true)
self._hold_handled = true
end

View File

@@ -127,7 +127,7 @@ function CheckButton:onTapCheckButton()
if not self.enabled then return true end
if self.tap_input then
self:onInput(self.tap_input)
elseif type(self.tap_input_func) == "function" then
elseif self.tap_input_func then
self:onInput(self.tap_input_func())
else
if G_reader_settings:isFalse("flash_ui") then
@@ -184,7 +184,7 @@ function CheckButton:onHoldCheckButton()
elseif self.hold_input then
self:onInput(self.hold_input, true)
self._hold_handled = true
elseif type(self.hold_input_func) == "function" then
elseif self.hold_input_func then
self:onInput(self.hold_input_func(), true)
self._hold_handled = true
end

View File

@@ -152,7 +152,7 @@ function IconButton:onHoldIconButton()
self.hold_callback()
elseif self.hold_input then
self:onInput(self.hold_input)
elseif type(self.hold_input_func) == "function" then
elseif self.hold_input_func then
self:onInput(self.hold_input_func())
elseif not self.hold_callback then -- nil or false
return