| 1971 | } |
| 1972 | |
| 1973 | bool Menu::process_key(int keyin) |
| 1974 | { |
| 1975 | // overall sequence given keyin: |
| 1976 | // 1. apply any keyfilter (currently: entirely unused!) |
| 1977 | // 2. apply any pre_process transformation |
| 1978 | // 3. try converting to a command (get_command, often overridden) |
| 1979 | // a. if the key is skipped (usually by a subclass), return CMD_NO_CMD |
| 1980 | // b. return the results of the key_to_command mapping |
| 1981 | // 4. if this got a command, run the command |
| 1982 | // 5. otherwise proceed to manual key handling on keyin |
| 1983 | // |
| 1984 | // n.b. superclasses can override process_key to preempt these steps as |
| 1985 | // well. Various special cases, e.g. digits for quantity menus |
| 1986 | // |
| 1987 | // webtiles complication alert: most of the menu navigation key handling |
| 1988 | // has a separate client-side implementation (for UI responsivenss), and |
| 1989 | // this function may not be called for arbitrary client-side keys! |
| 1990 | |
| 1991 | if (!is_set(MF_SHOW_EMPTY) && items.empty()) |
| 1992 | { |
| 1993 | lastch = keyin; |
| 1994 | return false; |
| 1995 | } |
| 1996 | |
| 1997 | if (f_keyfilter) |
| 1998 | keyin = f_keyfilter(keyin); |
| 1999 | keyin = pre_process(keyin); |
| 2000 | |
| 2001 | #ifdef USE_TILE_WEB |
| 2002 | const int old_vis_first = get_first_visible(); |
| 2003 | #endif |
| 2004 | if (keyin == ' ' |
| 2005 | && !!(flags & MF_MULTISELECT) && !!(flags & MF_ARROWS_SELECT)) |
| 2006 | { |
| 2007 | // XX allow customizing this mapping |
| 2008 | keyin = '.'; |
| 2009 | } |
| 2010 | |
| 2011 | command_type cmd = CMD_NO_CMD; |
| 2012 | if (is_set(MF_SELECT_QTY) && !is_set(MF_NOSELECT) && isadigit(keyin)) |
| 2013 | { |
| 2014 | // override cmd bindings for quantity digits |
| 2015 | if (num > 999) |
| 2016 | num = -1; |
| 2017 | num = (num == -1) ? keyin - '0' : |
| 2018 | num * 10 + keyin - '0'; |
| 2019 | } |
| 2020 | else |
| 2021 | cmd = get_command(keyin); |
| 2022 | |
| 2023 | if (cmd != CMD_NO_CMD) |
| 2024 | { |
| 2025 | lastch = keyin; // TODO: remove lastch |
| 2026 | return process_command(cmd); |
| 2027 | } |
| 2028 | |
| 2029 | switch (keyin) |
| 2030 | { |
nothing calls this directly
no test coverage detected