From 973b19aba0726c161a218bd5343c89d931a5d949 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 21 Aug 2009 16:34:41 +0200 Subject: [PATCH] awful.menu: fix default key handling Signed-off-by: Julien Danjou --- lib/awful/menu.lua.in | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in index f4f8f57d..b356af4e 100644 --- a/lib/awful/menu.lua.in +++ b/lib/awful/menu.lua.in @@ -31,7 +31,18 @@ local tonumber = tonumber module("awful.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 theme = {} @@ -320,16 +331,6 @@ function toggle(menu, keygrabber) 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. -- @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. @@ -338,10 +339,6 @@ function new(menu, parent, num) -- Create a table to store our menu informations local data = {} - if not menu_keys.up then - setkeys(menu.keys) - end - data.items = {} data.num = num or 1 data.theme = parent and parent.theme or load_theme(menu)