flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Mclean (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-28045) FocusManager throws TypeError
Date Wed, 17 Jul 2013 08:30:50 GMT

    [ https://issues.apache.org/jira/browse/FLEX-28045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13710855#comment-13710855
] 

Justin Mclean commented on FLEX-28045:
--------------------------------------

Code used to try and reproduce:


<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx">
	<s:layout>
		<s:VerticalLayout />
	</s:layout>
	
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.managers.FocusManager;

			override protected function createChildren():void {
				super.createChildren();
				
				var focus = new FocusManager(grid);
				focus.defaultButton = button;
			}
			
		]]>
	</fx:Script>
	
	<s:DataGrid id="grid" />
	<s:TextInput id="text" />
	<s:Button id="button" />
	
</s:Application>

                
> FocusManager throws TypeError
> -----------------------------
>
>                 Key: FLEX-28045
>                 URL: https://issues.apache.org/jira/browse/FLEX-28045
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: .Unspecified - Framework
>    Affects Versions: Adobe Flex SDK 4.5.1 (Release)
>         Environment: Affected OS(s): All OS Platforms
> Affected OS(s): All OS Platforms
> Browser: Other (specify version)
> Language Found: English
>            Reporter: Adobe JIRA
>              Labels: easyfix, easytest
>
> Steps to reproduce:
> 1. In some MXML component (a dialog or application), create a Grid with a mx:TextInput
and a mx:Button. The grid is called "myGrid" and the button is called "myButton"
> 2. Overload createChildren of the enclosing component. Inside createChildren (after calling
super.createChildren), set the focusmanager:
> 	myFocus = new FocusManager( myGrid );
> 	myFocus.defaultButton = myButton;
> 3. Run the app. Click in the textinput, enter some text and hit 'Enter'.
>  
>  Actual Results:
>  The app throws an error:
> TypeError: Error #1009: Cannot access a property or method of a null object reference.
> 	at mx.managers::FocusManager/defaultButtonKeyHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\FocusManager.as:2082]
>  
>  Expected Results:
> No error...
>  
>  Workaround (if any):
> Unknown 
>  
>  Comments:
> I have not made the effort of understanding the complete code of the FocusManager, but
I understand the following: FocusManager has 2 vars to keep track of the default button: defaultButton
and defButton. It seems that defaultButton is the 'designated' defaultbutton and defButton
the current default button, being null if there can not be any focus. In the key handler,
the following code causes the error:
>     private function defaultButtonKeyHandler(event:KeyboardEvent):void
>     {        
>         var sm:ISystemManager = form.systemManager;
>         if (hasEventListener("defaultButtonKeyHandler"))
>     		if (!dispatchEvent(new FocusEvent("defaultButtonKeyHandler", false, true)))
> 	    		return;
>             
>         if (defaultButtonEnabled && event.keyCode == Keyboard.ENTER &&
>             defaultButton && defButton.enabled)
>         {
>             sendDefaultButtonEvent();
>     }
>     }
> In the second if-clause, the code doesn't check whether defButton is null. It seems odd
that the code checks defaultButton for null and then accesses defButton, not defaultButton.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message