     {
         // When gaining focus, show the selection.  Uses the SelectionFormat 
         // values defined by the SelectionManager.
-        if (textFlow.interactionManager.hasSelection())
+        if (textFlow.interactionManager && 
+            textFlow.interactionManager.hasSelection())
+        {
             textFlow.flowComposer.showSelection();
+    }
     }
 
     /**

            
        // When losing focus, hide the selection.  Uses the SelectionFormat 
        // values defined by the SelectionManager. 
        if (textFlow.interactionManager.hasSelection())
            textFlow.flowComposer.hideSelection();            
    }

    //--------------------------------------------------------------------------

            selectionVisibility == TextSelectionVisibility.ALWAYS ?
            1.0 : 0.0;
            
        // The cursor is black, inverted, which makes it the inverse color
        // of the background, for maximum readability.         
        interactionManager.focusSelectionFormat = new SelectionFormat(
            selectionColor, 1.0, BlendMode.NORMAL, 
            0x000000, 1.0, BlendMode.INVERT);
        
        interactionManager.noFocusSelectionFormat = new SelectionFormat(
            unfocusedSelectionColor, unfocusedAlpha, BlendMode.NORMAL,
