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 | |
parent | cf0681f1ba2e4538122111e5631cf43ccd08dd44 (diff) | |
download | fluxbox-b4aba1ff12e455cb5fb6f76dee93f405bfe5738e.zip fluxbox-b4aba1ff12e455cb5fb6f76dee93f405bfe5738e.tar.bz2 |
minor fix in keyboard navigation
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Menu.cc | 69 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 4 |
2 files changed, 57 insertions, 16 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); |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 1803241..82a253d 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -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.hh,v 1.16 2003/07/02 05:26:45 fluxgen Exp $ | 25 | // $Id: Menu.hh,v 1.17 2003/07/03 12:23:28 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FBTK_MENU_HH | 27 | #ifndef FBTK_MENU_HH |
28 | #define FBTK_MENU_HH | 28 | #define FBTK_MENU_HH |
@@ -89,6 +89,8 @@ public: | |||
89 | void nextItem(); | 89 | void nextItem(); |
90 | /// select previous item | 90 | /// select previous item |
91 | void prevItem(); | 91 | void prevItem(); |
92 | void enterSubmenu(); | ||
93 | void enterParent(); | ||
92 | 94 | ||
93 | void disableTitle(); | 95 | void disableTitle(); |
94 | void enableTitle(); | 96 | void enableTitle(); |