I want to create a composite UI element. This is a class that provides a reusable layout of labels and buttons which can be placed inside a sidebar (or I suppose a full-screen view).
The current version of it looks like this:
CODE
var BTVOfferingWidget = new KONtx.Class(
{
ClassName: 'BTVOfferingWidget',
Extends: KONtx.element.Container,
config: {
focus: true
},
placeholder: 0,
_createContent: function()
{
log("BTVOfferingWidget._createContent()");
this.controls = {};
var optionArray = this.config.optionArray;
var l1 = this.controls.l1 = new KONtx.element.Text({
data: this.config.debugLabel,
styles: {
wrap:true,
width: this.width,
color: '#d0ffd0',
vOffset: 0//this.menuTitle.outerHeight
}
}).appendTo(this);
log("encoding options ["+optionArray.length+"]");
this.controls.toggle = new KONtx.control.ToggleButton({
label: "Encoding: ",
value: "0",
options: optionArray,
styles: {
vOffset: l1.outerHeight,
width: this.width
}
}).appendTo(this);
}
}
);
My problems with it currently are
1) the ToggleButton inside can't receive focus.
2) I have to manually call _createContent
I have experimented with deriving from a KONtx.element.Container and a KONtx.control.Button
The YWE Developer Guide has no examples of creating your own reusable composite widgets and browsing the source for existing widgets does not exactly make things obvious.
PageIndicator isn't a composite widget. Neither is Grid. Dialogs appear to be
from Mars. The keyboard looks like it should be composite, but the source for ReuseKeyboard.js makes my head spin. There are many other elements and controls I have not yet experimented with enough to know if they could be considered composite widgets.
What is the YWE idiom for reusable composite interface elements?