Currently:
- A caller needs to call |openTab(tabtype, args...)|, where |tabtype| is
a string representing the tab type ("message", "folder", etc), and
|args| is a variable number of tab-specific parameters.
- An implementer needs to implement |openTab(tab, args...)|, where |tab|
is the object representing the new tab, and |args| is the same as |args|
above.
Unfortunately, I needed to add a parameter for whether the tab was to be
opened in the background or the foreground, and this system can't really
support this (or any other additional generic parameters, really).
I decided to fix this by changing the openTab API to use named
parameters instead of varargs. Once bug 467768 lands, the API is going
to be:
- for a caller, |openTab(tabtype, args)|. |tabtype| is the same as
before, but |args| is now an object, with tab-specific parameters the
properties of the object.
- for an implementer, |openTab(tab, args)|. |tab| is the same as before,
and |args| is now the object passed in by the caller. The optional
function |shouldSwitchTo| is going to change similarly, with |args...|
now becoming |args| the object.
There's also going to be an optional parameter called |background| on
|args|. If set to true, the tab is going to be opened in the background.
If set to false or not given, the tab is going to be opened in the
foreground. If you're an implementer, you might have to change the
behaviour of your code depending on this, so it's going to be passed in
to you as part of |args|.
So, right now, to open a message tab with aMsgHdr, you need to write:
tabmail.openTab("message", aMsgHdr);
After the patch lands:
tabmail.openTab("message", {msgHdr: aMsgHdr});
If you want to open a message tab in the background:
tabmail.openTab("message", {msgHdr: aMsgHdr, background: true});
So what if you make dynamic objects? For example:
var args = [];
args["test1"] = test;
args["test2"] = test2;
/* and if you haven't guessed, both test and test2 are arguments that
were passed to my tab creator function (which is the function that has
the above args code in it). They might be null or they might have
values. What their values are or where this runs is not important. */
Could you still pass args defined as a variable pointer to an object
or does args have to be within an object itself?
var tabmail = document.getElementById('tabmail');
tabmail.openTab("mytabtype",args);
Why are you trying to assign properties to an array? I think what you
want here is
var args = {};
args["test1"] = test;
args["test2"] = test2;
or, alternatively (in a way that produces the same results and IMO looks
cleaner)
var args = {};
args.test1 = test;
args.test2 = test2;
or, possibly even better
var args = {test1: test, test2: test2};
In these cases, yes, |tabmail.openTab("mytabtype", args);| will work.
What I'm doing above:
tabmail.openTab("message", {msgHdr: aMsgHdr, background: true});
is the same as doing
var args = {msgHdr: aMsgHdr, background: true};
tabmail.openTab("message", args);
>
> Could you still pass args defined as a variable pointer to an object
args *is* a reference to an object. (I'm assuming you mean "reference"
when you say "pointer").
> or does args have to be within an object itself?
I'm not sure what you mean by this.
This patch has now landed, so in all probability you're going to see the
new openTab API in Thunderbird 3.0b3.
Seems to be working fine in:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1pre) Gecko/20090628 Lightning/1.0pre Shredder/3.0b3pre ID:20090628150113
A very large step forward IMO
One very minor nit: no option to save sessions or not when closing TB
The tabs seem to be saved and restored correctly, however.
JoeS