Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#412 closed defect (fixed)

ToolbarButtonGroup doesn't set itself up fully when constructed from markup

Reported by: Laurie Harper Owned by: anonymous
Priority: high Milestone:
Component: Widgets Version: 0.2
Keywords: Cc:
Blocked By: Blocking:

Description

ToolbarButtonGroup? doesn't connect the onSelect event or apply its defaultButton property if its children are created using markup rather than by calling addChild. As a result, the default button will not be selected, and clicking on a child button will not deselect the selected button.

Here's a patch to fix it:

Index: src/widget/Toolbar.js =================================================================== --- src/widget/Toolbar.js (revision 3021) +++ src/widget/Toolbar.js (working copy) @@ -561,18 +561,28 @@

if this is set to a number, the button at that index will be selected this.defaultButton = "";

  • var oldAddChild = this.addChild;

+ this.postCreate = function() { + for (var i = 0; i < this.children.length; i++) { + this._injectChild(this.children[i]); + } + } + + var oldAddChild = this.addChild;

this.addChild = function(item, pos, props) {

var widget = dojo.widget.ToolbarItem?.make(item, null, dojo.lang.mixin(props
{}, {toggleItem:true}));
  • dojo.event.connect(widget, "onSelect", this, "onChildSelected");

var ret = oldAddChild.call(this, widget, null, pos, null);

+ this._injectChild(widget); + return ret; + } + + this._injectChild = function(widget) { + dojo.event.connect(widget, "onSelect", this, "onChildSelected");

if(widget._name == this.defaultButton

(typeof this.defaultButton == "number"

&& this.children.length-1 == this.defaultButton)) { widget.select(false, true);

}

  • return ret;
  • }

+ }

this.getItem = function(name) {

if(name instanceof dojo.widget.ToolbarItem?) { return name; }

Change History (2)

comment:1 Changed 14 years ago by anonymous

Resolution: fixed
Status: newclosed

Thanks for the patch. Checked in as #3158.

comment:2 Changed 12 years ago by (none)

Milestone: 0.3release

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.