Closed Bug 502407 Opened 15 years ago Closed 15 years ago

Can't switch tabs/focus arbitrary tabs via AppleScript

Categories

(Camino Graveyard :: OS Integration, enhancement)

All
macOS
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: alqahira, Assigned: alqahira)

Details

(Whiteboard: [camino-2.0])

Attachments

(1 file)

We have no way of selecting an arbitrary tab via AppleScript.

Safari 3 and up use the obnoxious

tell {front window|window n} to set current tab to tab 1

which is better than nothing.  If OmniWeb has a way of doing this, it's even more obscure and I can't deduce it :P

Ideally, I'd expect

set current tab of browser window 1 to tab 2 of browser window 1

or possibly even

select tab 1 of browser window 1

to work.  We could do the "tell (browser window) n" thing to be compatible with Safari's syntax, but I'm not sure that's so important, particularly since I had to have the Internet tell me it existed.
"select" seems to be a core AppleScript command, but I can't figure out where it's defined or what it's expected to act upon; I don't see it in the AppleScript Language Guide.  We obviously don't want to redefine it if it's not intended to select single objects but is instead about selecting (highlighting) ranges or something else.
selectTabViewItem: is our Cocoa bit to do this?
For this you would want to use selectTabViewItemAtIndex:
Attached patch fixSplinter Review
With some help from my friends Chris, Stuart, and Uncle Google, we can now switch tabs programmatically :)
Assignee: nobody → alqahira
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #404771 - Flags: review?(stuart.morgan+bugzilla)
Comment on attachment 404771 [details] [diff] [review]
fix

>+    [[NSScriptCommand currentCommand] setScriptErrorString:[NSString stringWithFormat:@"The tab to select must be in the same window.", nil]];

This should just be
  [[NSScriptCommand currentCommand] setScriptErrorString:@"The tab to select must be in the same window."];

r=smorgan with that change.
Attachment #404771 - Flags: superreview?(mikepinkerton)
Attachment #404771 - Flags: review?(stuart.morgan+bugzilla)
Attachment #404771 - Flags: review+
Comment on attachment 404771 [details] [diff] [review]
fix

sr=pink

+- (void)setCurrentTab:(BrowserWrapper *)newTabItemView;
+{
+  NSTabViewItem* newTabItem = [newTabItemView tab];

Use consistent spacing on Foo* vs. Foo *. Prefer Foo*.
Attachment #404771 - Flags: superreview?(mikepinkerton) → superreview+
Landed on CAMINO_2_0_BRANCH and cvs trunk with Stuart's change and with Foo * to match every other instance in the file ;-)

We can file a follow-up bug to make ScriptingSupport.mm's *s not make pink cry.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [camino-2.0]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: