FLTK logo

STR #1648

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 2.0 | Post Text | Post File | SVN ⇄ GIT ]

STR #1648

Application:FLTK Library
Status:5 - New
Priority:1 - Request for Enhancement, e.g. asking for a feature
Scope:3 - Applies to all machines and operating systems
Subsystem:Core Library
Summary:Menu browsing wrap around
Version:2.0-feature
Created By:syrja
Assigned To:Unassigned
Fix Version:2.0-feature
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]

No files


Trouble Report Comments:

Post Text ]
Name/Time/Date Text  
 
#1 syrja
13:16 Apr 04, 2007
One very annoying feature in FLTK is that browsing menus with up and down arrow keys do not wrap around. In most Windows and KDE applications pressing down arrow key at the end of menu selects topmost menu item and pressing up key at the top moves to last item. This does not seem to happen in FLTK.

I'm not sure if this is intended behavior or just some kind of bug, but what follows is some quick hacks with FLTK2 source code to enable menu wrap around.

I made following modifications to Menu_popup.cxx (added or modified lines marked with //##):

static bool forward(MenuState& p, int menu) {
  // go to next item in menu menu if possible
  MWindow &m = *(p.menus[menu]);
  for (int item = p.indexes[menu]+1; item < m.children; item++) {
    Widget* widget = m.get_widget(item);
    if (widget->takesevents()) return setitem(p, menu, item);
  }
  for (int item = 0; item < p.indexes[menu]; item++) { //##
    Widget* widget = m.get_widget(item); //##
    if (widget->takesevents()) return setitem(p, menu, item); //##
  } //##
  return false;
}

static bool backward(MenuState& p, int menu) {
  // previous item in menu menu if possible
  MWindow &m = *(p.menus[menu]);
  for (int item = p.indexes[menu]-1; item >= 0; item--) {
    Widget* widget = m.get_widget(item);
    if (widget->takesevents()) return setitem(p, menu, item);
  }
  for (int item = m.children-1; item > p.indexes[menu]; item--) { //##
    Widget* widget = m.get_widget(item); //##
    if (widget->takesevents()) return setitem(p, menu, item); //##
  } //##
  return false;
}

int MWindow::handle(int event) {
...
    case UpKey:
      if (p.hmenubar && p.level == 0) backward(p, 1); //##
      else if (backward(p, p.level));
      else if (p.hmenubar) setitem(p, 0, p.indexes[0]);
      return 1;
...
}

Initial tests with Windows XP SP2 and Mandriva Linux 2007/KDE (sorry, I don't have Mac...) seem to work. So, what do you think?

    Mikko
 
 
#2 fabien
02:38 Apr 05, 2007
I took this opportunity to have a deeper look
to this backward forward feature.

I corrected this features and also many bugs
related to disabled item forwarding/backwarding and other  side-effects

It's working great on my branch and will be fixed
with this (autorolling feature) in my next merge.

Thanks,
Fabien
 
 
#3 TobiasFar
03:17 Mar 15, 2008
Has someone already fixed this? If yes could the person commit it. :)  
 
#4 fabien
13:08 Dec 09, 2014
unassigning myself from discontinued 2.x branch  
     

Return to Bugs & Features | Post Text | Post File ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.