Fix tests

This commit is contained in:
Insality 2023-02-07 18:58:24 +02:00
parent bd9b4ad58f
commit cfaeff1516
2 changed files with 8 additions and 4 deletions

View File

@ -248,6 +248,10 @@ function Button.on_input(self, action_id, action)
return false return false
end end
if not self:is_enabled() then
return false
end
local is_pick = true local is_pick = true
local is_key_trigger = (action_id == self.key_trigger) local is_key_trigger = (action_id == self.key_trigger)
if not is_key_trigger then if not is_key_trigger then
@ -280,7 +284,7 @@ function Button.on_input(self, action_id, action)
-- While hold button, repeat rate pick from input.repeat_interval -- While hold button, repeat rate pick from input.repeat_interval
if action.repeated then if action.repeated then
if not self.disabled and self.on_repeated_click:is_exist() and self.can_action then if self.on_repeated_click:is_exist() and self.can_action then
on_button_repeated_click(self) on_button_repeated_click(self)
return true return true
end end
@ -290,7 +294,7 @@ function Button.on_input(self, action_id, action)
return on_button_release(self) return on_button_release(self)
end end
if not self.disabled and self.can_action and self.on_long_click:is_exist() then if self.can_action and self.on_long_click:is_exist() then
local press_time = socket.gettime() - self.last_pressed_time local press_time = socket.gettime() - self.last_pressed_time
if self.style.AUTOHOLD_TRIGGER <= press_time then if self.style.AUTOHOLD_TRIGGER <= press_time then

View File

@ -11,7 +11,7 @@ return function()
local function create_drag_instance(on_drag) local function create_drag_instance(on_drag)
local button = mock_gui.add_box("button", 0, 0, 20, 20) local button = mock_gui.add_box("button", 0, 0, 20, 20)
local instance = druid:new_drag(button, on_drag) local instance = druid:new_drag(button, on_drag)
instance.style.IS_USE_SCREEN_KOEF = false instance.style.NO_USE_SCREEN_KOEF = true
instance.style.DRAG_DEADZONE = 4 instance.style.DRAG_DEADZONE = 4
return instance return instance
end end
@ -36,7 +36,7 @@ return function()
local instance = create_drag_instance(on_drag) local instance = create_drag_instance(on_drag)
druid:on_input(mock_input.click_pressed(10, 10)) druid:on_input(mock_input.click_pressed(10, 10))
assert(instance.is_touch == true) assert(instance.is_touch == true)
druid:on_input(mock_input.input_empty(12, 10)) druid:on_input(mock_input.input_empty(12, 10))
assert(on_drag_mock.calls == 0) assert(on_drag_mock.calls == 0)