mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
keygrabber: Add :remove_keybinding()
.
It was possible to add new keys, but not remove existing ones.
This commit is contained in:
parent
f0a7f904f9
commit
c391fc7fe4
1 changed files with 22 additions and 0 deletions
|
@ -549,6 +549,7 @@ end
|
|||
-- @tparam awful.key key The key.
|
||||
-- @tparam string description.group The keybinding group
|
||||
-- @noreturn
|
||||
-- @see remove_keybinding
|
||||
|
||||
function keygrabber:add_keybinding(key, keycode, callback, description)
|
||||
local mods = not key._is_awful_key and key or nil
|
||||
|
@ -581,6 +582,27 @@ function keygrabber:add_keybinding(key, keycode, callback, description)
|
|||
end
|
||||
end
|
||||
|
||||
--- Remove a keybinding from the keygrabber.
|
||||
--
|
||||
-- @method remove_keybinding
|
||||
-- @treturn boolean `true` if removed, `false` if not found.
|
||||
-- @see add_keybinding
|
||||
|
||||
function keygrabber:remove_keybinding(key)
|
||||
for idx, obj in ipairs(self._private.keybindings[key.key]) do
|
||||
if obj == key then
|
||||
table.remove(self._private.keybindings[key.key], idx)
|
||||
|
||||
if #self._private.keybindings[key.key] == 0 then
|
||||
self._private.keybindings[key.key] = nil
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function keygrabber:set_root_keybindings(keys)
|
||||
local real_keys = {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue