Focusable / subfocusable

Charles Goodwin <[email protected]> Thu, 02 Oct 2003 15:18:48 +0100
Newsgroups gmane.comp.java.xwt.widgets
Organization XWT Foundation
Message-ID <[email protected]>
I'm making a change here.

Rather than having subfocusable, focusable, and enabled, it's going to 
be just focusable and enabled.

Basically, it's a case of before having 3 where 2 will do.

If you want to temporarily disable your widget, enable = false.  If you 
don't want it to be part of the focusable chain, put focusable = false.

Before:
> _enabled = function( e ) {
>     arguments.cascade( e );
>     // sync focusable
>     focusable = e;
> }
> 
> _focusable = function( f ) {
>     // if we're being made unfocusable, make sure we're not focused
>     if ( !f and focused ) focused = false;
>     // can only be focusable if we're enabled and not subfocusable
>     arguments.cascade( f and enabled and !subfocusable );
> }
> 
> _subfocusable = function( s ) {
>     arguments.cascade( s );
>     if ( s ) {
>         focusable = false;
>         if ( surface ) syncsurface = thisbox;
>     }
>     else focused = false;
> }

Now:
> focusable += function() {
>     return cascade and enabled and visible;
> }
> 
> focusable += function( v ) {
>     cascade = v;
>     syncsurface = thisbox;
> }

Note: enabled is now implied since there's no longer a need to trap it 
to affect focusable.  Also, this way, focusable is 'remembered' whereas 
before it could be affected by a put to enabled or subfocusable.  It was 
almost a 'sub property' before that was used by other properties.

So now 'focusable=false' drops the widget from the surface.  A 
'focusable=true' is part of a surface - although not always focusable 
(depending upon whether it's enabled and visible.

Let me know if I'm making a big mistake. :)

- Charlie