def handle_keys
      @selected = false
      @repaint_required = true # added 2011-12-12 otherwise keeps repainting and you see a flicker
      @toggle_key ||= 27 # default switch off with ESC, if nothing else defined
      set_menu 0
      begin
      catch(:menubarclose) do
      while((ch = @window.getchar()) != @toggle_key )
       #$log.debug "menuubar inside handle_keys :  #{ch}"  if ch != -1
        case ch
        when -1
          next
        when KEY_DOWN
    
          if !@selected
            current_menu.fire
          else
            current_menu.handle_key ch
          end
            
          @selected = true
        when KEY_ENTER, 10, 13, 32
          @selected = true
          ret = current_menu.handle_key ch
          #break; ## 2008-12-29 18:00  This will close after firing anything
          break if ret == :CLOSE
        when KEY_UP
          current_menu.handle_key ch
        when KEY_LEFT
          ret = current_menu.handle_key ch
          prev_menu if ret == :UNHANDLED
        when KEY_RIGHT
          ret = current_menu.handle_key ch
          next_menu if ret == :UNHANDLED
        when ?\C-g.getbyte(0) # abort
          throw :menubarclose
        else
          ret = current_menu.handle_key ch
          if ret == :UNHANDLED
            Ncurses.beep 
          else
            break  # we handled a menu action, close menubar (THIS WORKS FOR MNEMONICS ONLY and always)
          end
        end
        Ncurses::Panel.update_panels();
        Ncurses.doupdate();

        @window.wrefresh
      end
      end # catch
      ensure
        #ensure is required becos one can throw a :close
        $log.debug " DESTROY IN ENSURE"
        current_menu.clear_menus
        @repaint_required = false
        destroy  # Note that we destroy the menu bar upon exit
      end
    end
def handle_keys
      @selected = false
      @repaint_required = true # added 2011-12-12 otherwise keeps repainting and you see a flicker
      @toggle_key ||= 27 # default switch off with ESC, if nothing else defined
      set_menu 0
      begin
      catch(:menubarclose) do
      while((ch = @window.getchar()) != @toggle_key )
       #$log.debug "menuubar inside handle_keys :  #{ch}"  if ch != -1
        case ch
        when -1
          next
        when KEY_DOWN
    
          if !@selected
            current_menu.fire
          else
            current_menu.handle_key ch
          end
            
          @selected = true
        when KEY_ENTER, 10, 13, 32
          @selected = true
          ret = current_menu.handle_key ch
          #break; ## 2008-12-29 18:00  This will close after firing anything
          break if ret == :CLOSE
        when KEY_UP
          current_menu.handle_key ch
        when KEY_LEFT
          ret = current_menu.handle_key ch
          prev_menu if ret == :UNHANDLED
        when KEY_RIGHT
          ret = current_menu.handle_key ch
          next_menu if ret == :UNHANDLED
        when ?\C-g.getbyte(0) # abort
          throw :menubarclose
        else
          ret = current_menu.handle_key ch
          if ret == :UNHANDLED
            Ncurses.beep 
          else
            break  # we handled a menu action, close menubar (THIS WORKS FOR MNEMONICS ONLY and always)
          end
        end
        Ncurses::Panel.update_panels();
        Ncurses.doupdate();

        @window.wrefresh
      end
      end # catch
      ensure
        #ensure is required becos one can throw a :close
        $log.debug " DESTROY IN ENSURE"
        current_menu.clear_menus
        @repaint_required = false
        destroy  # Note that we destroy the menu bar upon exit
      end
    end
menubar LEFT, RIGHT, DOWN