【问题标题】:In flex 3, need to make part of checkbox label to be bold在 flex 3 中,需要将复选框标签的一部分设置为粗体
【发布时间】:2012-09-03 15:21:38
【问题描述】:

在 flex 3 中,如何将复选框标签的一部分设为粗体? 说复选框标签是“记住数据网格上的值”。需要将文本“datagrid”单独加粗。任何人都可以请帮忙。 提前致谢。

【问题讨论】:

    标签: actionscript-3 apache-flex flex3


    【解决方案1】:

    这不是完美的解决方案,但可以帮助您入门。如果你扩展 CheckBox 类,你可以重写 updateDisplayList() 方法,并使用它的 htmlText 属性设置复选框的标签。

    然后使用这个自定义复选框并传入带有 HTML 的标签。

    这个解决方案的问题:

    • 超类没有测量 HTML 格式的文本(您可以实现 measure() Flex 生命周期方法)
    • 在 super.updateDisplayList() 完成所有工作后,我们使用 htmlText 属性将其撤消

    HTMLTextCheckBox.as:

    package
    {
        import mx.controls.CheckBox;
    
        public class HtmlTextCheckBox extends CheckBox
        {
            public function HtmlTextCheckBox()
            {
                super();
            }
    
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
            {
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                textField.htmlText = label;
            }
        }
    }
    

    使用 MXML:

    <local:HtmlTextCheckBox label="this is the &lt;b&gt;bold part&lt;/b&gt;"/>
    

    或者在 AS3 中:

    var cb:HtmlTextCheckBox = new HtmlTextCheckBox();
    cb.text = "this is the <b>bold part</b>";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-17
      • 1970-01-01
      • 2021-12-31
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 2020-09-24
      相关资源
      最近更新 更多