awful.menu: fix default key handling
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
435716af73
commit
973b19aba0
|
@ -31,7 +31,18 @@ local tonumber = tonumber
|
||||||
module("awful.menu")
|
module("awful.menu")
|
||||||
|
|
||||||
local cur_menu
|
local cur_menu
|
||||||
local menu_keys = {}
|
|
||||||
|
--- Key bindings for menu navigation.
|
||||||
|
-- Keys are: up, down, exec, back, close. Value are table with a list of valid
|
||||||
|
-- keys for the action, i.e. menu_keys.up = { "j", "k" } will bind 'j' and 'k'
|
||||||
|
-- key to up action. This is common to all created menu.
|
||||||
|
-- @class table
|
||||||
|
-- @name menu_keys
|
||||||
|
menu_keys = { up = { "Up" },
|
||||||
|
down = { "Down" },
|
||||||
|
exec = { "Return", "Right" },
|
||||||
|
back = { "Left" },
|
||||||
|
close = { "Escape" } }
|
||||||
|
|
||||||
local function load_theme(custom)
|
local function load_theme(custom)
|
||||||
local theme = {}
|
local theme = {}
|
||||||
|
@ -320,16 +331,6 @@ function toggle(menu, keygrabber)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set key bindings for menu navigation.
|
|
||||||
-- @param keys Table containing the following keys: up, down, exec, back, close. If a key is missing the default key binding will be used, defaults are respectively: "Up", "Down", "Return", "Left", "Escape".
|
|
||||||
function setkeys(keys)
|
|
||||||
menu_keys.up = keys and keys.up or { "Up" }
|
|
||||||
menu_keys.down = keys and keys.down or { "Down" }
|
|
||||||
menu_keys.exec = keys and keys.exec or { "Return", "Right" }
|
|
||||||
menu_keys.back = keys and keys.back or { "Left" }
|
|
||||||
menu_keys.close = keys and keys.close or { "Escape" }
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Open a menu popup.
|
--- Open a menu popup.
|
||||||
-- @param menu Table containing the menu informations. Key items: Table containing the displayed items, each element is a tab containing: item name, tiggered action, submenu table or function, item icon (optional). Keys [fg|bg]_[focus|normal], border, border_width, submenu_icon, height and width override the default display for your menu, each of them are optional. Key auto_expand controls the submenu auto expand behaviour by setting it to true (default) or false.
|
-- @param menu Table containing the menu informations. Key items: Table containing the displayed items, each element is a tab containing: item name, tiggered action, submenu table or function, item icon (optional). Keys [fg|bg]_[focus|normal], border, border_width, submenu_icon, height and width override the default display for your menu, each of them are optional. Key auto_expand controls the submenu auto expand behaviour by setting it to true (default) or false.
|
||||||
-- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user.
|
-- @param parent Specify the parent menu if we want to open a submenu, this value should never be set by the user.
|
||||||
|
@ -338,10 +339,6 @@ function new(menu, parent, num)
|
||||||
-- Create a table to store our menu informations
|
-- Create a table to store our menu informations
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
if not menu_keys.up then
|
|
||||||
setkeys(menu.keys)
|
|
||||||
end
|
|
||||||
|
|
||||||
data.items = {}
|
data.items = {}
|
||||||
data.num = num or 1
|
data.num = num or 1
|
||||||
data.theme = parent and parent.theme or load_theme(menu)
|
data.theme = parent and parent.theme or load_theme(menu)
|
||||||
|
|
Loading…
Reference in New Issue