Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Titanium Mobile 用のうすーーーい TabGroup Wrapper
class AppTabGroup
constructor: (glb = globals) ->
@tabGroup = Ti.UI.createTabGroup()
@tabGroup.addEventListener "focus", (e) ->
glb.currentTab = e.tab
return
getTabGroup: () ->
return @tabGroup
appendTab: (param) ->
tab = Ti.UI.createTab param
@tabGroup[param.tabId] = tab if param.tabId? and typeof param.tabId is "string"
@tabGroup.addTab if param.tabId then @tabGroup[param.tabId] else tab
return
open: (defaultTab = 0) ->
@tabGroup.setActiveTab defaultTab
@tabGroup.open()
return
# Modularization
module.exports = AppTabGroup
@ryugoo

This comment has been minimized.

Copy link
Owner Author

ryugoo commented Jun 27, 2012

How to use (CoffeeScript)

AppTabGroup = require "AppTabGroup"
tabGroup = new AppTabGroup()
tabGroup.appendTab
    tabId: "tab0" # [String] Tab ID parameter
    title: "Tab"
    window: Ti.UI.createWindow
        title: "Window"
        backgroundColor: "#FFFFFF"
tabGroup.open(0) # [Number] Default tab index (0 start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.