Adobe Air: scroller throws error when changes focus between different applications

前端 未结 4 1521
梦毁少年i
梦毁少年i 2021-01-21 06:04
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at spark.components::Scroller/focusInHandler()[E:\\dev\\4.y\\frameworks\\proje         


        
相关标签:
4条回答
  • 2021-01-21 06:44

    I ran into the same issue, and the root cause was that PopUpManager/PopUpAnchor would not properly set the focusManager if the component being popped up does not implement the IFocusManagerContainer interface. After implementing such interface, the problem goes away.

    0 讨论(0)
  • 2021-01-21 06:44

    I know this is old but here is a solution that works for me.

    dataGrid.scroller.addEventListener(FocusEvent.FOCUS_IN, dataGridFocusInHandler, false, 1);
    

    and

    protected function dataGridFocusInHandler(event:FocusEvent):void {
        if(dataGrid.scroller.focusManager == null) {
            event.stopImmediatePropagation();
        }
    }
    

    could also been applied to a list I anticipate

    Cheers Adz

    0 讨论(0)
  • 2021-01-21 06:58

    I've got the same problem in one of my projects and looks like it's known bug of SDK. In my case I just wrote custom Scroller class where added focusManager != null check. Something like

    package components
    {
        import flash.events.FocusEvent;
        import spark.components.Scroller;
        public class MyScroller extends Scroller
        {
            public function MyScroller()
            {
                super();
            }
    
            override protected function focusInHandler(event:FocusEvent):void
            {
                if(focusManager != null) {
                    super.focusInHandler(event);
                }
            }
        }
    }
    

    Best regrads, Roman

    0 讨论(0)
  • 2021-01-21 06:59

    I was having this issue, and it turns out that it was caused by some buttons I had as item renderers in my grid. These buttons would change the view to a different section, and apparently keep focus after pressed, causing all sorts of trouble. I set them to focusEnabled=false, and it solved the problem.

    0 讨论(0)
提交回复
热议问题