Skip to main content
January 27, 2013
Question

This focus issue is a tough one

  • January 27, 2013
  • 2 replies
  • 2237 views

Gidday guys

This one has been bugging me all day.

If I select a row in my datagrid, then click out of my AIR desktop app to another program, desktop etc, then click back into the AIR app, I get the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at fl.controls::TextInput/setFocus()

    at fl.managers::FocusManager/activateHandler()

I set up the following to deselect the row, but the error still occurs:

data_grid.addEventListener(Event.DEACTIVATE, deselectRow, false, 0, true);

           

private function deselectRow(event:Event):void

{           

      data_grid.selectedIndex = null;

}

Anyone had this happen before and know of a fix?

Cheers

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
January 27, 2013

what line of code is triggering the null error?  (click file>publish settings>swf and tick "permit debugging")

January 27, 2013

That's strange - it's not happening anymore. I'll try and re-create the erro.

kGlad - I'm yet to set up debugging for CS6 - since I upgraded, the debugger doesn't work.

Thanks guys

February 5, 2013

enable those properties only when ctrl or shift are pressed.  otherwise, disable them.


OK - I think I've got around it...

I've left in...

data_grid.focusEnabled = false;

data_grid.mouseFocusEnabled = false;  

... in the set up for the data grid, so the shift and ctrl pressed functions work correctly.

I've added...

stage.addEventListener(Event.DEACTIVATE, displayDeactivated, false, 0, true);

       

private function displayDeactivated(event:Event):void { stage.focus = stage; }

...so that the focus is completely taken away from the datagrid if someone minimizes or clicks out of the app. Clicking back in the app no longer throws the error.

Ned Murphy
Legend
January 27, 2013

Normally a non-selection for a list is assigned -1, not null.  I don't know if that is part of your problem or not.