|
From: Joe E. <jen...@fl...> - 2006-01-25 04:32:50
|
Steve Landers wrote:
> The main issue I've struck so far has been limitations with the
> notebook widget. Whilst I suspect that notebook can do everything I
> want, I find it much less convenient to use than the BWidget notebook.
>
> For example, BWidget NoteBook has a raisecmd option, that causes the
> specified command to be run when a tab is raised.
We considered this issue earlier -- see the mailing list archives
for details if you're interested [1], relevant discussion was
between 2004-09-10 and 2004-09-13. Summarizing:
You can replace '-raisecmd' and '-leavecmd' with <Map> and
<Unmap> bindings on the slave windows, or with a <<NotebookTabChanged>>
binding on the notebook.
With the first option, the binding scripts can fire for other
reasons besides tab selection (main window withdrawn, nested
notebooks, etc.). This may or may not be what you want.
If you _don't_ want that, and there are heterogeneous -raisecmd's,
a useful approach is to generate your own <<TabRaised>> virtual
events:
bind $nb <<NotebookTabChanged>> {
event generate [lindex [%W tabs] [%W index current]] <<TabRaised>>
}
If you need to generate <<TabLowered>> events too (-leavecmd),
you'll need to keep track of the previous tab by hand.
(But again, <Unmap> bindings might be what you want instead).
Finally, if you're using -leavecmd to control whether the
tab should switch or not (that's the BWidget feature whereby
the user can select a new tab, and the application can say
"Oh no you don't!"), you're on your own; there's no easy
built-in support for this sort of thing.
> Also, it allows symbolic names for tabs. I use this extensively,
> [... example elided ... ]
> [...] I then have to discover which tab was raised.
> Sounds simple, but without symbolic names for tabs I can either use
> the numeric index (which will breaks because not all tabs are
> displayed) or the tab text (which will break because the application
> is multilingual). I'm assuming that I could use the child pane
> window,
Yes, the child window names will work as tab identifiers.
> except I don't see any way of retrieving it.
This is a Frequently Asked Question, with a not very satisfactory
answer :-(. The canonical way to get the name of the currently-selected
tab is [lindex [$nb tabs] [$nb index current]].
There really ought to be a more straightforward way to access this.
[$nb current] maybe?
[1] http://sourceforge.net/mailarchive/forum.php?forum_id=42051&viewmonth=200409
--Joe English
jen...@fl...
|