Re: The new focus model
David Crawshaw <[email protected]> Tue, 6 Jan 2004 08:53:52 +1000
| Newsgroups | gmane.comp.java.xwt.widgets |
|---|---|
| Message-ID | <[email protected]> |
On 06/01/2004, at 8:05 AM, Charles Goodwin wrote:
> I see that surface has to preapply focuspane - but this is
> automatically
> handled through xwt.theme.surface, right?
For Widget Developers:
<template theme:preapply="focusable">
focused += function(v) { if (v) { ... light up pretty colours ... } }
KeyPressed += function(key) {
xwt.log.debug("I've received a key event.");
}
Press1 += function(v) {
xwt.log.debug("I've received a mouse event.");
}
</template>
For Theme Developers:
Every root box (any box that calls xwt.ui.frame=thisbox) must preapply
xwt.theme.surface. This box handles the surface object (like the old
thisbox.root object). If any box asks for thisbox.surface, the core
walks up the parents to a root box and returns the object stored in the
variable called 'surface'.
Theme implementations of xwt.theme.surface have to provide a series of
functions for managing focusable objects. These functions are detailed
in xwt.theme.surface.
The default implementation of these functions is in xwt.lib.focuspane,
which I can envisage almost every theme using.
Each theme implementation of xwt.theme.surface (eg.
org.xwt.theme.win2k.surface) must trap key events and changing
focusable objects can all the correct function.
xwt.theme.focusable registers itself with its surface, using the
functions documented in xwt.theme.surface. It receives key events as
xwt.theme.surface sees fit, through the core traps,
KeyPressed/KeyReleased.
Eventually xwt.theme.surface will be preapplied automatically when
someone calls xwt.ui.frame = thisbox. Until then, any box that makes
that call must also preapply xwt.theme.surface.
If you have any widgets that need to be tracked per-surface, you should
do the tracking with surface.*() functions in xwt.theme.surface.
Everything above should currently be working, otherwise tell me, it's a
bug. Only thing really left to do is that previously mentioned
automatic apply of xwt.theme.surface to any root boxes.
d