alt+ TAB行为实现
我正在尝试实现 ALT + TAB 行为。
我想知道用户何时按住 ALT 键。
为什么这个释放功能不起作用?
awful.key(
{},
'Alt_L',
function()
altHold = true
end,
function()
altHold = false
end
),
不切实际的解决方案:
awful.key(
{},
'Alt_L',
function()
altHold = true
end
),
awful.key(
{'Mod1'},
'Alt_L',
nil,
function()
altHold = false
end
)
这可行,但任何其他带 ALT 的热键都不再起作用。
其他解决方案:
keygrabber.run(
function (mod, key, event)
-- Stop alt-tabbing when the alt-key is released
if gears.table.hasitem(mod, "Mod1") then
if (key == "Alt_L" or key == "Escape") and event == "release" then
-- Make it visible
if key == "Escape" then
-- Cancel client selection
end
else
-- Raise clients in order to restore history
-- raise chosen client on top of all
-- restore minimized clients
end
end
keygrabber.stop()
-- Pressed tab
elseif key == "Tab" and event == "press" then
if gears.table.hasitem(mod, "Shift") then
-- Move to previous client on Shift-Tab
cyclePreview(-1)
else
-- Move to next client on each Tab-press
cyclePreview( 1)
end
end
end
end
)
这是 Troglobit 的稍微修改版本:
https://github.com/troglobit/ Awesome-switcher/blob/master/init.lua#L470-L525\
按下 ALT + TAB 时会调用此函数。
按住 ALT 的同时,按下一个 TAB 键将调用 previewCycle()
函数。
如果 ALT 被释放,它将选择所选的客户端。
ESCAPE 取消选择。
I'm trying to implement ALT + TAB behaviour.
I want to know when a user is holding the ALT key.
Why does this release function not work?
awful.key(
{},
'Alt_L',
function()
altHold = true
end,
function()
altHold = false
end
),
IMPRACTICAL SOLUTION:
awful.key(
{},
'Alt_L',
function()
altHold = true
end
),
awful.key(
{'Mod1'},
'Alt_L',
nil,
function()
altHold = false
end
)
This works, but any other hotkeys with ALT no longer work.
OTHER SOLUTION:
keygrabber.run(
function (mod, key, event)
-- Stop alt-tabbing when the alt-key is released
if gears.table.hasitem(mod, "Mod1") then
if (key == "Alt_L" or key == "Escape") and event == "release" then
-- Make it visible
if key == "Escape" then
-- Cancel client selection
end
else
-- Raise clients in order to restore history
-- raise chosen client on top of all
-- restore minimized clients
end
end
keygrabber.stop()
-- Pressed tab
elseif key == "Tab" and event == "press" then
if gears.table.hasitem(mod, "Shift") then
-- Move to previous client on Shift-Tab
cyclePreview(-1)
else
-- Move to next client on each Tab-press
cyclePreview( 1)
end
end
end
end
)
This is a slightly modified version from Troglobit:
https://github.com/troglobit/awesome-switcher/blob/master/init.lua#L470-L525\
This gets called when ALT + TAB is pressed.
While holding ALT, the next TAB press calls previewCycle()
function.
If ALT is released it selects the chosen client.
ESCAPE cancels the selection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
随机猜测:释放键时,“ alt”修饰符处于活动状态,因此您需要一个用
mod1
作为修改器的键框(ISAlt
mod1 我不确定)。但是,当然,这种键绑定将不会对钥匙按下反应,因此您需要两个。
Random guess: When the key is released, the "alt" modifier is active, so you need a keybinding with
Mod1
as modifier (isAlt
Mod1
? I'm not entirely sure). But of course, that key binding would then not react to key presses, so you need two.