3 Replies Latest reply on Nov 1, 2006 9:21 AM by FlightGuy

    Adding keyboard support for a canvas component

    bmont
      I've tried and tried but I cannot get a canvas component to listen for keyboard events.

      I have even tried to set the focus to the canvas but even though it seems to have taked focus it has not. The documentation is very poor when on the topic of focus handling and keyboard handling.

      Is there anything I can do to a Canvas component so that it accepts focus and listens for keyboard events?
        • 1. Re: Adding keyboard support for a canvas component
          FlightGuy Level 1
          Try extending the canvas control, and make your extension implement the IFocusManagerComponent interface.
          • 2. Re: Adding keyboard support for a canvas component
            bmont Level 1
            I have tried to do this but it doesn't seem to work. From my understanding of interfaces I should have to implement the methods. If so, what methods need to be implemented and how?

            What seems to happen is that the component is not added to the Focus Manager list of focusable objects. I tried to use the setFocus() method but that doesn't work either.
            • 3. Re: Adding keyboard support for a canvas component
              FlightGuy Level 1
              There is actually code in the base class that tests for whether the (extended) class implements the interface, so you don't need to add any methods - the interface itself is used as a "marker interface". Try setting the focusEnabled property to true as well (if you haven't already).

              If none of this works, have a look at the source of the canvas class - from within flexBuilder, hold down Ctrl and click on the reference to Canvas in your class (extends...). This should open the source in your editor and you can search for "focus" and probably find our where it's going wrong.