Created
May 3, 2011 13:39
-
-
Save oetiker/953340 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mainContainer = new qx.ui.window.Window("Toolbar").set({ | |
layout : new qx.ui.layout.VBox(20), | |
contentPadding: 0, | |
width: 400, | |
height: 300 | |
}); | |
this.getRoot().add(mainContainer, {left:20, top:20}); | |
mainContainer.open(); | |
/////////////////////////////////////////////////////////////// | |
// Toolbar stuff | |
/////////////////////////////////////////////////////////////// | |
// create the toolbar | |
toolbar = new qx.ui.toolbar.ToolBar(); | |
toolbar.setSpacing(5); | |
mainContainer.add(toolbar); | |
var overflowMenu = new qx.ui.menu.Menu(); | |
var overflow = new qx.ui.toolbar.MenuButton("More ...",null,overflowMenu); | |
for (var i = 0; i < 20;i++){ | |
var tbBtn = new qx.ui.toolbar.Button('Button '+i); | |
toolbar.add(tbBtn); | |
toolbar.setRemovePriority(tbBtn,i); | |
var mnBtn = new qx.ui.menu.Button('Button '+i); | |
mnBtn.exclude(); | |
overflowMenu.add(mnBtn); | |
tbBtn.setUserData('mnBtn',mnBtn); | |
} | |
toolbar.addSpacer(); | |
toolbar.add(overflow); | |
toolbar.set({ | |
spacing: 5, | |
overflowHandling: true, | |
overflowIndicator: overflow | |
}); | |
var showHideHandler = function(item, visibility) { | |
item.getUserData('mnBtn').setVisibility(visibility); | |
}; | |
// handler for showind and hiding toobar items | |
toolbar.addListener("showItem", function(e) { | |
showHideHandler(e.getData(), "excluded"); | |
}, this); | |
toolbar.addListener("hideItem", function(e) { | |
showHideHandler(e.getData(), "visible"); | |
}, this); | |
// naive me would expect this not to be neccessary | |
tbBtn.addListenerOnce('appear',function(){ | |
var pane = this.getLayoutParent(); | |
this.fireDataEvent('resize', pane.getBounds()); | |
},toolbar); | |
// nor this | |
toolbar.getOverflowIndicator().addListener('appear',function(){ | |
var pane = this.getLayoutParent(); | |
this.fireDataEvent('resize', pane.getBounds()); | |
},toolbar); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment