Copyright © 2008, 2009 Arndt Roger Schneider
Gstripes provides three functions for drawing focus frames –highlighting. The most simple variant is focusframes, which is also implemented as a vanilla Tk version.
Drawing Focus
focusframes, implemented in TkPath and Tk Canvas.
focuspathes, implemented in TkPath only.
focuscirlces, implemented in TkPath only.
The other two functions focuspathes and focuscirlces require TkPath. They use the circle or path element from TkPath.
The focus-ring is drawn outside and around the control. A series of focus rings is drawn –four– to mimic fading into white space.
These three functions can be used directly for any control. They are internally used by Gstripes for every hijacked window. A non-hijacked window can receive a focus-ring generated inside a Gstripes window, by using event handlers for the »FocusIn« and »FocusOut« event. Best practice is to create a focus-ring on the FocusIn event and to destroy this focus-ring when the FocusOut event is received.
Example 6.39. FocusIn
... $stripes.back delete focus_$window # The highlighting is invisible at first... $stripes focusframes \ [list $l $t $r $b] $highlightThickness \ $highlightColor $radius \ [list $window ${type}_$window \ focus_$window] # Let the focus-ring appear... gstripes::interactive $stripes \ $window <FocusIn> focus_$window ... # Monitor the configure event, in order # to synchronize focusframes and window. bind $window <Configure> ...
The Example 6.39, “FocusIn” fragment displays how such an external focus-ring can be made. The variable »window« is the external window for which a focus-ring is needed. The variable »stripes« is the Gstripes window in which the focus-ring is created. The variables »l« , »t« , »r« and »b« are the window’s boundaries.
The focus-ring is at first invisible, the call to »gstripes::interactive« makes it visible.