-- keyboardNavigation_FrameLoop
-----------------------------------
-- DESCRIPTION:
--                frame loop and keyboard input "watcher"
--                keyboard navigation using control+tab to access the menu without mouse
--
-- REQUIRES:
--                none
--
-- USAGE:
--                put this behavior on a framescript in order to loop on that frame
--                and track whether the user presses ctrl + TAB
--                Currently it is set to track the whole time, therefore the menus even appear
--                if the app is not in foreground.
--                A deactivate application trigger could change that. I am ok with it myself
--                and I even sometimes look up items, when I am in other apps like bbedit...
-----------------------------------



property pActive

on exitFrame me
  
  ----------------------- keyboardcontrol:
  if the controldown then
    if not(pActive) then
      
      if keypressed(48) then -- TAB key
        if the shiftdown then -- CTRL + SHIFT + TAB open handler menu
          sendSprite(xscr().mGetKanal(#handlerMenuTrigger), #mousedown)
        else -- CTRL + TAB open utitlities menu
          sendSprite(xscr().mGetKanal(#utilitiesMenuTrigger), #mousedown)
        end if
        pActive = 1
      end if
      
    end if
  else
    pActive = 0
  end if
  ----------------------- // keyboardcontrol
  
  go the frame
end
