Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hotkey.lua: add isActive #3608

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion extensions/hotkey/hotkey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ function hotkey.modal:enter()
end
for _,hk in ipairs(self.keys) do enable(hk,nil,true) end
self:entered()
self._isActive = true
return self
end

Expand All @@ -564,6 +565,7 @@ function hotkey.modal:exit()
if (self.k) then
enable(self.k)
end
self._isActive = false
self:exited()
log.d('Exited modal')
return self
Expand All @@ -589,7 +591,8 @@ end
--- Notes:
--- * If `key` is nil, no global hotkey will be registered (all other parameters will be ignored)
function hotkey.modal.new(mods, key, message)
local m = setmetatable({keys = {}}, hotkey.modal)
local m = setmetatable({keys = {}}, hotkey.modal)
m._isActive = false
if (key) then
m.k = hotkey.bind(mods, key, message, function() m:enter() end)
end
Expand All @@ -615,4 +618,8 @@ function hotkey.modal:delete()
end
end

function hotkey.modal:isActive()
return self._isActive
end

return hotkey
Loading