You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Greg Brown <gk...@mac.com> on 2009/08/09 23:36:54 UTC

Re: svn commit: r802460 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java

I was going to email you about this over the weekend, but I didn't  
bother since my mom only has dial-up and I didn't think you'd actually  
be working on this one. I've been giving a lot of thought as to how to  
solve the menu issues, and I think it will require some changes to the  
focus system, including this method. Oh well.  :-)  We can talk about  
it in more detail tomorrow.


On Aug 8, 2009, at 5:39 PM, tvolkert@apache.org wrote:

> Author: tvolkert
> Date: Sat Aug  8 21:39:58 2009
> New Revision: 802460
>
> URL: http://svn.apache.org/viewvc?rev=802460&view=rev
> Log:
> PIVOT-187 :: Fix Container.requestFocus()
>
> Modified:
>    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java
>
> Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ 
> Container.java
> URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java?rev=802460&r1=802459&r2=802460&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ 
> Container.java (original)
> +++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ 
> Container.java Sat Aug  8 21:39:58 2009
> @@ -445,15 +445,31 @@
>      */
>     @Override
>     protected boolean requestFocus(boolean temporary) {
> -        if (isShowing()) {
> +        boolean success = false;
> +
> +        if (isShowing()
> +            && isEnabled()) {
>             FocusTraversalPolicy focusTraversalPolicy =  
> getFocusTraversalPolicy();
> -            Component component =  
> focusTraversalPolicy.getNextComponent(this, null, Direction.FORWARD);
> -            if (component != null) {
> -                component.requestFocus();
> +
> +            if (focusTraversalPolicy != null) {
> +                Component component = null;
> +
> +                do {
> +                    component =  
> focusTraversalPolicy.getNextComponent(this, component,  
> Direction.FORWARD);
> +
> +                    // TODO Detect infinite loop that can occur if  
> the focus
> +                    // traversal policy loops and every component  
> it returns
> +                    // yields false when requestFocus() is called  
> on it
> +
> +                    if (component != null) {
> +                        success = component.requestFocus(temporary);
> +                    }
> +                } while (component != null
> +                    && !success);
>             }
>         }
>
> -        return containsFocus();
> +        return success;
>     }
>
>     /**
>
>


Re: svn commit: r802460 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java

Posted by Greg Brown <gk...@mac.com>.
Oops - meant to send to Todd directly - my mom's internet connection  
is probably not of interest to pivot-dev in general (and probably not  
even to Todd).  :-)

G


On Aug 9, 2009, at 5:36 PM, Greg Brown wrote:

> I was going to email you about this over the weekend, but I didn't  
> bother since my mom only has dial-up and I didn't think you'd  
> actually be working on this one. I've been giving a lot of thought  
> as to how to solve the menu issues, and I think it will require some  
> changes to the focus system, including this method. Oh well.  :-)   
> We can talk about it in more detail tomorrow.
>
>
> On Aug 8, 2009, at 5:39 PM, tvolkert@apache.org wrote:
>
>> Author: tvolkert
>> Date: Sat Aug  8 21:39:58 2009
>> New Revision: 802460
>>
>> URL: http://svn.apache.org/viewvc?rev=802460&view=rev
>> Log:
>> PIVOT-187 :: Fix Container.requestFocus()
>>
>> Modified:
>>   incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java
>>
>> Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ 
>> Container.java
>> URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java?rev=802460&r1=802459&r2=802460&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ 
>> Container.java (original)
>> +++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ 
>> Container.java Sat Aug  8 21:39:58 2009
>> @@ -445,15 +445,31 @@
>>     */
>>    @Override
>>    protected boolean requestFocus(boolean temporary) {
>> -        if (isShowing()) {
>> +        boolean success = false;
>> +
>> +        if (isShowing()
>> +            && isEnabled()) {
>>            FocusTraversalPolicy focusTraversalPolicy =  
>> getFocusTraversalPolicy();
>> -            Component component =  
>> focusTraversalPolicy.getNextComponent(this, null, Direction.FORWARD);
>> -            if (component != null) {
>> -                component.requestFocus();
>> +
>> +            if (focusTraversalPolicy != null) {
>> +                Component component = null;
>> +
>> +                do {
>> +                    component =  
>> focusTraversalPolicy.getNextComponent(this, component,  
>> Direction.FORWARD);
>> +
>> +                    // TODO Detect infinite loop that can occur if  
>> the focus
>> +                    // traversal policy loops and every component  
>> it returns
>> +                    // yields false when requestFocus() is called  
>> on it
>> +
>> +                    if (component != null) {
>> +                        success = component.requestFocus(temporary);
>> +                    }
>> +                } while (component != null
>> +                    && !success);
>>            }
>>        }
>>
>> -        return containsFocus();
>> +        return success;
>>    }
>>
>>    /**
>>
>>
>