aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-01-16 11:02:54 (GMT)
committerfluxgen <fluxgen>2004-01-16 11:02:54 (GMT)
commitbc672d4a1db5e6f61455146478bcb97d6f042db6 (patch)
treebd412471eea74512dab0c3d62825b2234640015b
parent8cb258d68a842af632236c6c4158af5e4aee78c6 (diff)
downloadfluxbox-bc672d4a1db5e6f61455146478bcb97d6f042db6.zip
fluxbox-bc672d4a1db5e6f61455146478bcb97d6f042db6.tar.bz2
menu keyboard navigation fixes, patch from Junichiro Kita
-rw-r--r--src/FbTk/Menu.cc48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index d0caf9e..4554541 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.52 2004/01/08 22:07:00 fluxgen Exp $ 25// $Id: Menu.cc,v 1.53 2004/01/16 11:02:54 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -253,9 +253,6 @@ void Menu::lower() {
253} 253}
254 254
255void Menu::nextItem() { 255void Menu::nextItem() {
256 if (which_press >= 0 && which_press == static_cast<signed>(menuitems.size() - 1))
257 return;
258
259 int old_which_press = which_press; 256 int old_which_press = which_press;
260 257
261 if (old_which_press >= 0 && 258 if (old_which_press >= 0 &&
@@ -264,26 +261,24 @@ void Menu::nextItem() {
264 if (menuitems[old_which_press]->submenu()) { 261 if (menuitems[old_which_press]->submenu()) {
265 // we need to do this explicitly on the menu.window 262 // we need to do this explicitly on the menu.window
266 // since it might hide the parent if we use Menu::hide 263 // since it might hide the parent if we use Menu::hide
267 menuitems[old_which_press]->submenu()->menu.window.hide(); 264 menuitems[old_which_press]->submenu()->internal_hide();
268 } 265 }
269 drawItem(old_which_press, false, true, true); 266 drawItem(old_which_press, false, true, true);
270 } 267 }
271 268
272 // restore old in case we changed which_press 269 // restore old in case we changed which_press
273 which_press = old_which_press; 270 which_press = old_which_press;
274 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size())) 271 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size() - 1))
275 which_press = 0; 272 which_press = 0;
276 else if (which_press > 0 && which_press < static_cast<signed>(menuitems.size() - 1)) 273 else
277 which_press++; 274 which_press++;
278 275
279 276
280 if (menuitems[which_press] == 0) 277 if (menuitems[which_press] == 0)
281 return; 278 return;
282 279
283 if (menuitems[which_press]->submenu()) 280
284 drawSubmenu(which_press); 281 drawItem(which_press, true, true, true);
285 else
286 drawItem(which_press, true, true, true);
287 282
288} 283}
289 284
@@ -295,24 +290,23 @@ void Menu::prevItem() {
295 if (menuitems[old_which_press]->submenu()) { 290 if (menuitems[old_which_press]->submenu()) {
296 // we need to do this explicitly on the menu.window 291 // we need to do this explicitly on the menu.window
297 // since it might hide the parent if we use Menu::hide 292 // since it might hide the parent if we use Menu::hide
298 menuitems[old_which_press]->submenu()->menu.window.hide(); 293 menuitems[old_which_press]->submenu()->internal_hide();
299 } 294 }
300 drawItem(old_which_press, false, true, true); 295 drawItem(old_which_press, false, true, true);
301 } 296 }
302 // restore old in case we changed which_press 297 // restore old in case we changed which_press
303 which_press = old_which_press; 298 which_press = old_which_press;
304 299
305 if (which_press < 0 || which_press >= static_cast<signed>(menuitems.size())) 300 if (which_press <= 0 || which_press >= static_cast<signed>(menuitems.size()))
306 which_press = 0; 301 which_press = menuitems.size() - 1;
307 else if (which_press - 1 >= 0) 302 else if (which_press - 1 >= 0)
308 which_press--; 303 which_press--;
309 304
310 if (menuitems[which_press] != 0) { 305 if (menuitems[which_press] == 0)
311 if (menuitems[which_press]->submenu()) 306 return;
312 drawSubmenu(which_press); 307
313 else 308
314 drawItem(which_press, true, true, true); 309 drawItem(which_press, true, true, true);
315 }
316 310
317} 311}
318 312
@@ -324,6 +318,10 @@ void Menu::enterSubmenu() {
324 if (submenu == 0) 318 if (submenu == 0)
325 return; 319 return;
326 320
321 if (submenu->menuitems.size() == 0)
322 return;
323
324 drawSubmenu(which_press);
327 submenu->grabInputFocus(); 325 submenu->grabInputFocus();
328 submenu->which_press = -1; // so we land on 0 after nextItem() 326 submenu->which_press = -1; // so we land on 0 after nextItem()
329 submenu->nextItem(); 327 submenu->nextItem();
@@ -335,11 +333,14 @@ void Menu::enterParent() {
335 333
336 Menu *submenu = menuitems[which_press]->submenu(); 334 Menu *submenu = menuitems[which_press]->submenu();
337 if (submenu) 335 if (submenu)
338 submenu->menu.window.hide(); 336 submenu->internal_hide();
339 337
340 drawItem(which_press, false, true, true); 338 drawItem(which_press, false, true, true);
341 which_press = -1; // dont select any in this 339 which_press = -1; // dont select any in this
342 // return focus to parent but keep this window open 340 // hide self
341 visible = false;
342 menu.window.hide();
343 // return focus to parent
343 parent()->grabInputFocus(); 344 parent()->grabInputFocus();
344} 345}
345 346
@@ -1324,7 +1325,8 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1324 break; 1325 break;
1325 case XK_Return: 1326 case XK_Return:
1326 // send fake button 1 click 1327 // send fake button 1 click
1327 if (which_press >= 0 && which_press < static_cast<signed>(menuitems.size())) { 1328 if (which_press >= 0 && which_press < static_cast<signed>(menuitems.size()) &&
1329 isItemEnabled(which_press)) {
1328 menuitems[which_press]->click(1, event.time); 1330 menuitems[which_press]->click(1, event.time);
1329 itemSelected(1, which_press); 1331 itemSelected(1, which_press);
1330 m_need_update = true; 1332 m_need_update = true;