formatbtn.lzx
<library>
<include href="../stylishbutton.lzx"/>
<class name="formatbtn" extends="stylishbutton" width="26" focusable="false" style="formatbtn_style">
<attribute name="format" type="string"/>
<attribute name="isactive" value="false
" setter="this.setActive(isactive)"/>
<attribute name="toolbar" value="$once{this.parent}"/>
<attribute name="editor" value="$once{this.parent.editor}"/>
<attribute name="activecolor" value="0xEAE4B7
"/>
<attribute name="activetooltiptext" value="
" type="string"/>
<attribute name="inactivetooltiptext" value="
" type="string"/>
<tooltip name="tooltip" text="standin only">
<method name="showTip">
this.text = (parent.isactive ? parent.activetooltiptext : parent.inactivetooltiptext);
super.showTip();
</method>
</tooltip>
<method name="init">
super.init();
toolbar.registerTool(this,format);
</method>
<method name="setActive" args="isactive">
this.isactive = isactive;
if (this.isinited) {
var color = ( this.isactive ? this.activecolor : this.tint );
if (this['left']) this.setTint(this.left, color);
if (this['middle']) this.setTint(this.middle, color);
if (this['right']) this.setTint(this.right, color);
}
</method>
<handler name="onclick" method="doClick"/>
<method name="doClick" args="ignore=null">
// toggle it
this.setActive(!this.isactive);
if (this.toolbar._passthruchanges) {
this.editor.setFormatAttribute(this.format, this.isactive);
}
// Restore the selection immediately.
// Unlike the combo boxes, buttons aren't focusable, so we can just
// restore the selection in the same frame. No need for a delegate [ben 9.21.05]
this.editor._restoreSelection();
</method>
<handler name="onmouseover">
this.editor.saveSelectionRegion();
</handler>
<method name="getValue">
return isactive;
</method>
<method name="reset">
setActive(false);
</method>
<method name="setState" args="state">
setActive(state == 1);
</method>
</class>
</library>
Cross References
Includes
Classes
- <class name="formatbtn" extends="stylishbutton">