diff options
author | fluxgen <fluxgen> | 2003-07-03 12:23:28 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-07-03 12:23:28 (GMT) |
commit | b4aba1ff12e455cb5fb6f76dee93f405bfe5738e (patch) | |
tree | 10070318d74630b30eb30b8d7c473029ba20e2a7 /src/FbTk/Menu.cc | |
parent | cf0681f1ba2e4538122111e5631cf43ccd08dd44 (diff) | |
download | fluxbox-b4aba1ff12e455cb5fb6f76dee93f405bfe5738e.zip fluxbox-b4aba1ff12e455cb5fb6f76dee93f405bfe5738e.tar.bz2 |
minor fix in keyboard navigation
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r-- | src/FbTk/Menu.cc | 69 |
1 files changed, 54 insertions, 15 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index c953be9..75ead42 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Menu.cc,v 1.25 2003/07/02 05:26:14 fluxgen Exp $ | 25 | // $Id: Menu.cc,v 1.26 2003/07/03 12:23:28 fluxgen Exp $ |
26 | 26 | ||
27 | //use GNU extensions | 27 | //use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -1259,6 +1259,33 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) { | |||
1259 | } | 1259 | } |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | void Menu::enterSubmenu() { | ||
1263 | if (which_press < 0 || which_press >= menuitems.size()) | ||
1264 | return; | ||
1265 | |||
1266 | Menu *submenu = menuitems[which_press]->submenu(); | ||
1267 | if (submenu == 0) | ||
1268 | return; | ||
1269 | |||
1270 | submenu->grabInputFocus(); | ||
1271 | submenu->which_press = -1; // so we land on 0 after nextItem() | ||
1272 | submenu->nextItem(); | ||
1273 | } | ||
1274 | |||
1275 | void Menu::enterParent() { | ||
1276 | if (which_press < 0 || which_press >= menuitems.size() || parent() == 0) | ||
1277 | return; | ||
1278 | |||
1279 | Menu *submenu = menuitems[which_press]->submenu(); | ||
1280 | if (submenu) | ||
1281 | submenu->menu.window.hide(); | ||
1282 | |||
1283 | drawItem(which_press, false, true, true); | ||
1284 | which_press = -1; // dont select any in this | ||
1285 | // return focus to parent but keep this window open | ||
1286 | parent()->grabInputFocus(); | ||
1287 | } | ||
1288 | |||
1262 | void Menu::keyPressEvent(XKeyEvent &event) { | 1289 | void Menu::keyPressEvent(XKeyEvent &event) { |
1263 | KeySym ks; | 1290 | KeySym ks; |
1264 | char keychar[1]; | 1291 | char keychar[1]; |
@@ -1276,27 +1303,39 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1276 | case XK_Down: | 1303 | case XK_Down: |
1277 | nextItem(); | 1304 | nextItem(); |
1278 | break; | 1305 | break; |
1279 | case XK_Left: | 1306 | case XK_Left: // enter submenu or leave this menu and enter parent |
1280 | if (which_press >= 0 && which_press < menuitems.size() && | 1307 | // if we have a submenu we should determine if |
1281 | m_parent != 0) { | 1308 | // we should open it or close this and enter parent depending on which |
1282 | if (menuitems[which_press]->submenu()) | 1309 | // side the parent is. |
1283 | menuitems[which_press]->submenu()->menu.window.hide(); | 1310 | // if parent on the left -> enter parent |
1284 | drawItem(which_press, false, true, true); | 1311 | // if parent on the right -> enter submenu of this item |
1285 | m_parent->grabInputFocus(); | 1312 | if (which_press >= 0 && which_press < menuitems.size()) { |
1313 | Menu *submenu = menuitems[which_press]->submenu(); | ||
1314 | if (parent() && parent()->x() < x()) // parent on the left | ||
1315 | enterParent(); | ||
1316 | else if (submenu) // else parent on the right and submenu on the left | ||
1317 | enterSubmenu(); | ||
1286 | } | 1318 | } |
1287 | break; | 1319 | break; |
1288 | case XK_Right: | 1320 | case XK_Right: // enter submenu or leave this menu and enter parent |
1289 | if (which_press >= 0 && which_press < menuitems.size() && | 1321 | // if we have a submenu we should determine if |
1290 | menuitems[which_press]->submenu()) { | 1322 | // we should open it or close this and enter parent depending on which |
1291 | menuitems[which_press]->submenu()->grabInputFocus(); | 1323 | // side the parent is. |
1292 | menuitems[which_press]->submenu()->which_press = -1; | 1324 | // if parent on the left -> enter submenu of this item |
1293 | menuitems[which_press]->submenu()->nextItem(); | 1325 | // parent on the right -> leave this menu and enter parent |
1326 | if (which_press >= 0 && which_press < menuitems.size()) { | ||
1327 | Menu *submenu = menuitems[which_press]->submenu(); | ||
1328 | if (parent() && parent()->x() > x()) // parent on the right | ||
1329 | enterParent(); | ||
1330 | else if (submenu) // else parent on the left and submenu on the right | ||
1331 | enterSubmenu(); | ||
1294 | } | 1332 | } |
1295 | break; | 1333 | break; |
1296 | case XK_Escape: | 1334 | case XK_Escape: // close menu |
1297 | hide(); | 1335 | hide(); |
1298 | break; | 1336 | break; |
1299 | case XK_Return: | 1337 | case XK_Return: |
1338 | // send fake button 1 click | ||
1300 | if (which_press >= 0 && which_press < menuitems.size()) { | 1339 | if (which_press >= 0 && which_press < menuitems.size()) { |
1301 | menuitems[which_press]->click(1, event.time); | 1340 | menuitems[which_press]->click(1, event.time); |
1302 | itemSelected(1, which_press); | 1341 | itemSelected(1, which_press); |