加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex Multiline Button

发布时间:2020-12-15 04:26:35 所属栏目:百科 来源:网络整理
导读:Flex Multiline Button Posting mostly so I can find this again quickly. UPDATE:?posted working example (the code below does work). Right click – view source. Basically stolen straight from?Alex’s Flex Closet,but a button (not radio button

Flex Multiline Button

Posting mostly so I can find this again quickly.

UPDATE:?posted working example (the code below does work). Right click – view source.

Basically stolen straight from?Alex’s Flex Closet,but a button (not radio button),fixed casting,and just included the referenced class in the same file (less flexible,but,more convenient,maybe). Anyway – use just like a button but has multiple lines.

package components.multiLineButton
{
import flash.display.DisplayObject;
import flash.text.TextLineMetrics;

import mx.controls.Button;
import mx.core.IFlexDisplayObject;
import mx.core.mx_internal;
use namespace mx_internal;

public class MultiLineButton extends Button
{
public function MultiLineButton()
{
super();
}

override protected function createChildren():void
{
if (!textField)
{
textField = new NoTruncationUITextField();
textField.styleName = this;
addChild(DisplayObject(textField));
}

super.createChildren();

textField.multiline = true;
textField.wordWrap = true;
textField.width = width;
}

override protected function measure():void
{
if (!isNaN(explicitWidth))
{
var tempIcon:IFlexDisplayObject = getCurrentIcon();
var w:Number = explicitWidth;
if (tempIcon)
w -= tempIcon.width + getStyle("horizontalGap") + getStyle("paddingLeft") + getStyle("paddingRight");
textField.width = w;
}
super.measure();

}

override public function measureText(s:String):TextLineMetrics
{
textField.text = s;
var lineMetrics:TextLineMetrics = textField.getLineMetrics(0);
lineMetrics.width = textField.textWidth + 4;
lineMetrics.height = textField.textHeight + 4;
return lineMetrics;
}
}
}
import mx.core.UITextField;

class NoTruncationUITextField extends UITextField
{
public function NoTruncationUITextField()
{
super();
}
override public function truncateToFit(s:String = null):Boolean
{
return false;
}

}


转载:http://www.forestandthetrees.com/2008/03/11/flex-multiline-button/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读