def handle_key ch
      if !@current_menu.empty?
        cmenu = @current_menu.last
      else 
        cmenu = self
      end
      if !@@menus.empty?
       cmenu = @@menus.last
      else 
       cmenu = self
      end
      case ch
      when KEY_DOWN
        cmenu.select_next_item
        #return cmenu.fire # XXX 2010-10-16 21:39 trying out
        if cmenu.is_a? Canis::Menu 
          #alert "is a menu" # this gets triggered even when we are on items
        end
      when KEY_UP
        cmenu.select_prev_item
      when KEY_ENTER, 10, 13, 32 # added 32 2008-11-27 23:50 
        return cmenu.fire
      when KEY_LEFT
        if cmenu.parent.is_a? Canis::Menu 
       #$log.debug "LEFT IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
       #$log.debug "left IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
        end
        ret = cmenu.select_left_item # 2011-09-24 V1.3.1 attempt to goto left item if columns
        if ret == :UNHANDLED
          if cmenu.parent.is_a? Canis::MenuBar #and !cmenu.parent.current_menu.empty?
            #$log.debug " ABOU TO DESTROY DUE TO LEFT"
            cmenu.current_menu.pop
            @@menus.pop ## NEW
            cmenu.destroy
            return :UNHANDLED
          end
          # LEFT on a menu list allows me to close and return to higher level
          if cmenu.parent.is_a? Canis::Menu #and !cmenu.parent.current_menu.empty?
            #$log.debug " ABOU TO DESTROY DUE TO LEFT"
            cmenu.current_menu.pop
            @@menus.pop ## NEW
            cmenu.destroy
            #return :UNHANDLED
          end
        end
      when KEY_RIGHT
       $log.debug "RIGHTIN MENU : #{text}  "
       if cmenu.active_index
        if cmenu.items[cmenu.active_index].is_a?  Canis::Menu 
          #alert "could fire here cmenu: #{cmenu.text}, par: #{cmenu.parent.text} "
          cmenu.fire
          return
       #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
       #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
        end
       end
       # This introduces a bug if no open items
       ret = cmenu.select_right_item # 2011-09-24 V1.3.1 attempt to goto right item if columns
       #alert "attempting to select right #{ret} "
        if ret == :UNHANDLED
          #if cmenu.parent.is_a? Canis::Menu and !cmenu.parent.current_menu.empty?
          if cmenu.parent.is_a? Canis::MenuBar #and !cmenu.current_menu.empty?
            $log.debug " ABOU TO DESTROY DUE TO RIGHT"
            cmenu.current_menu.pop
            @@menus.pop
            cmenu.destroy
            return :UNHANDLED
          end
        end
      else
        ret = check_mnemonics cmenu, ch
        return ret
      end
    end
def handle_key ch
      if !@current_menu.empty?
        cmenu = @current_menu.last
      else 
        cmenu = self
      end
      if !@@menus.empty?
       cmenu = @@menus.last
      else 
       cmenu = self
      end
      case ch
      when KEY_DOWN
        cmenu.select_next_item
        #return cmenu.fire # XXX 2010-10-16 21:39 trying out
        if cmenu.is_a? Canis::Menu 
          #alert "is a menu" # this gets triggered even when we are on items
        end
      when KEY_UP
        cmenu.select_prev_item
      when KEY_ENTER, 10, 13, 32 # added 32 2008-11-27 23:50 
        return cmenu.fire
      when KEY_LEFT
        if cmenu.parent.is_a? Canis::Menu 
       #$log.debug "LEFT IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
       #$log.debug "left IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
        end
        ret = cmenu.select_left_item # 2011-09-24 V1.3.1 attempt to goto left item if columns
        if ret == :UNHANDLED
          if cmenu.parent.is_a? Canis::MenuBar #and !cmenu.parent.current_menu.empty?
            #$log.debug " ABOU TO DESTROY DUE TO LEFT"
            cmenu.current_menu.pop
            @@menus.pop ## NEW
            cmenu.destroy
            return :UNHANDLED
          end
          # LEFT on a menu list allows me to close and return to higher level
          if cmenu.parent.is_a? Canis::Menu #and !cmenu.parent.current_menu.empty?
            #$log.debug " ABOU TO DESTROY DUE TO LEFT"
            cmenu.current_menu.pop
            @@menus.pop ## NEW
            cmenu.destroy
            #return :UNHANDLED
          end
        end
      when KEY_RIGHT
       $log.debug "RIGHTIN MENU : #{text}  "
       if cmenu.active_index
        if cmenu.items[cmenu.active_index].is_a?  Canis::Menu 
          #alert "could fire here cmenu: #{cmenu.text}, par: #{cmenu.parent.text} "
          cmenu.fire
          return
       #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
       #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
        end
       end
       # This introduces a bug if no open items
       ret = cmenu.select_right_item # 2011-09-24 V1.3.1 attempt to goto right item if columns
       #alert "attempting to select right #{ret} "
        if ret == :UNHANDLED
          #if cmenu.parent.is_a? Canis::Menu and !cmenu.parent.current_menu.empty?
          if cmenu.parent.is_a? Canis::MenuBar #and !cmenu.current_menu.empty?
            $log.debug " ABOU TO DESTROY DUE TO RIGHT"
            cmenu.current_menu.pop
            @@menus.pop
            cmenu.destroy
            return :UNHANDLED
          end
        end
      else
        ret = check_mnemonics cmenu, ch
        return ret
      end
    end
def handle_key ch if ! @current_menu . empty? cmenu = @current_menu . last else cmenu = self end if ! @@menus . empty? cmenu = @@menus . last else cmenu = self end case ch when KEY_DOWN cmenu . select_next_item #return cmenu.fire # XXX 2010-10-16 21:39 trying out if cmenu . is_a? Canis :: Menu #alert "is a menu" # this gets triggered even when we are on items end when KEY_UP cmenu . select_prev_item when KEY_ENTER , 10 , 13 , 32 # added 32 2008-11-27 23:50  return cmenu . fire when KEY_LEFT if cmenu . parent . is_a? Canis :: Menu #$log.debug "LEFT IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}" #$log.debug "left IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}" end ret = cmenu . select_left_item # 2011-09-24 V1.3.1 attempt to goto left item if columns if ret == :UNHANDLED if cmenu . parent . is_a? Canis :: MenuBar #and !cmenu.parent.current_menu.empty? #$log.debug " ABOU TO DESTROY DUE TO LEFT" cmenu . current_menu . pop @@menus . pop ## NEW cmenu . destroy return :UNHANDLED end # LEFT on a menu list allows me to close and return to higher level if cmenu . parent . is_a? Canis :: Menu #and !cmenu.parent.current_menu.empty? #$log.debug " ABOU TO DESTROY DUE TO LEFT" cmenu . current_menu . pop @@menus . pop ## NEW cmenu . destroy #return :UNHANDLED end end when KEY_RIGHT $log . debug "RIGHTIN MENU : #{text}  " if cmenu . active_index if cmenu . items [ cmenu . active_index ] . is_a? Canis :: Menu #alert "could fire here cmenu: #{cmenu.text}, par: #{cmenu.parent.text} " cmenu . fire return #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}" #$log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}" end end # This introduces a bug if no open items ret = cmenu . select_right_item # 2011-09-24 V1.3.1 attempt to goto right item if columns #alert "attempting to select right #{ret} " if ret == :UNHANDLED #if cmenu.parent.is_a? Canis::Menu and !cmenu.parent.current_menu.empty? if cmenu . parent . is_a? Canis :: MenuBar #and !cmenu.current_menu.empty? $log . debug " ABOU TO DESTROY DUE TO RIGHT" cmenu . current_menu . pop @@menus . pop cmenu . destroy return :UNHANDLED end end else ret = check_mnemonics cmenu , ch return ret end end
menu LEFT, RIGHT, DOWN, UP, ENTER
 item could be menuitem or another menu
menu LEFT RIGHT DOWN UP ENTER item could be menuitem or another menu