- Adobe Flex 教程
- Flex - 首页
- Flex - 概述
- Flex - 环境
- Flex - 应用程序
- Flex - 创建应用程序
- Flex - 部署应用程序
- Flex - 生命周期阶段
- Flex - 使用 CSS 样式化
- Flex - 使用皮肤样式化
- Flex - 数据绑定
- Flex - 基本控件
- Flex - 表单控件
- Flex - 复杂控件
- Flex - 布局面板
- Flex - 视觉效果
- Flex - 事件处理
- Flex - 自定义控件
- Flex - RPC 服务
- Flex - FlexUnit 集成
- Flex - 调试应用程序
- Flex - 国际化
- Flex - 打印支持
- Adobe Flex 资源
- Flex - 快速指南
- Flex - 有用资源
- Flex - 讨论
Flex - RichTextEditor 控件
RichTextEditor 控件允许用户输入和格式化文本。用户可以更改字体系列、颜色、大小和样式,以及其他属性,例如文本对齐、项目符号和 URL 链接。该控件包含一个面板控件,其中有两个控件
一个文本区域控件,用户可以在其中输入文本。
一个包含格式控件的容器,允许用户指定文本特征。格式控件会影响正在键入的文本或选定的文本。
类声明
以下是 mx.controls.RichTextEditor 类的声明:
public class RichTextEditor extends Panel
公共属性
| 序号 | 属性和描述 |
|---|---|
| 1 | alignToolTip : String = "对齐" 当用户将鼠标悬停在文本对齐按钮上时出现的工具提示。 |
| 2 | boldToolTip : String = "粗体" 当用户将鼠标悬停在文本粗体按钮上时出现的工具提示。 |
| 3 | bulletToolTip : String = "项目符号" 当用户将鼠标悬停在项目符号列表按钮上时出现的工具提示。 |
| 4 | colorPickerToolTip : String = "颜色" 当用户将鼠标悬停在 ColorPicker 控件上时出现的工具提示。 |
| 5 | defaultLinkProtocol : String 在链接文本开头使用的默认协议字符串。 |
| 6 | fontFamilyToolTip : String = "字体系列" 当用户将鼠标悬停在字体下拉列表上时出现的工具提示。 |
| 7 | fontSizeToolTip : String = "字体大小" 当用户将鼠标悬停在字体大小下拉列表上时出现的工具提示。 |
| 8 | htmlText : String 包含 HTML 标记的文本,显示在 RichTextEditor 控件的 TextArea 子控件中。 |
| 9 | italicToolTip : String = "斜体" 当用户将鼠标悬停在文本斜体按钮上时出现的工具提示。 |
| 10 | linkToolTip : String = "链接" 当用户将鼠标悬停在链接文本输入字段上时出现的工具提示。 |
| 11 | selection : mx.controls.textClasses:TextRange [只读] 一个 TextRange 对象,包含 TextArea 子控件中选定的文本。 |
| 12 | showControlBar : Boolean 指定是否显示包含文本格式控件的控制栏。 |
| 13 | showToolTips : Boolean 指定是否为文本格式控件显示工具提示。 |
| 14 | text : String 不带标记的纯文本,显示在 RichTextEditor 控件的 TextArea 子控件中。 |
| 15 | underlineToolTip : String = "下划线" 当用户将鼠标悬停在文本下划线按钮上时出现的工具提示。 |
公共方法
| 序号 | 方法和描述 |
|---|---|
| 1 | RichTextEditor() 构造函数。 |
事件
| 序号 | 事件和描述 |
|---|---|
| 1 | change 当用户更改 TextArea 控件中文本的内容或格式时调度。 |
继承的方法
此类继承自以下类:
- mx.containers.Panel
- mx.core.Container
- mx.core.UIComponent
- mx.core.FlexSprite
- flash.display.Sprite
- flash.display.DisplayObjectContainer
- flash.display.InteractiveObject
- flash.display.DisplayObject
- flash.events.EventDispatcher
- Object
Flex RichTextEditor 控件示例
让我们按照以下步骤检查在 Flex 应用程序中使用 RichTextEditor 控件,方法是创建一个测试应用程序:
| 步骤 | 描述 |
|---|---|
| 1 | 在包 com.tutorialspoint.client 下创建一个名为 HelloWorld 的项目,如Flex - 创建应用程序章节中所述。 |
| 2 | 修改 HelloWorld.mxml,如下所述。保持其他文件不变。 |
| 3 | 编译并运行应用程序,以确保业务逻辑按要求工作。 |
以下是修改后的 mxml 文件 src/com.tutorialspoint/HelloWorld.mxml 的内容。
<?xml version = "1.0" encoding = "utf-8"?>
<s:Application xmlns:fx = "http://ns.adobe.com/mxml/2009"
xmlns:s = "library://ns.adobe.com/flex/spark"
xmlns:mx = "library://ns.adobe.com/flex/mx"
width = "100%" height = "100%" minWidth = "500" minHeight = "500">
<fx:Style source = "/com/tutorialspoint/client/Style.css" />
<fx:Script>
<![CDATA[
private var richTextString:String = "You can enter text into the"
+" <b>RichTextEditor control</b>.Click <b>"
+"<font color = '#BB50AA'>buttons</font></b> to display"
+" entered text as <i>plain text</i>, "
+"or as <i>HTML-formatted</i> text.";
]]>
</fx:Script>
<s:BorderContainer width = "630" height = "480" id = "mainContainer"
styleName = "container">
<s:VGroup width = "100%" height = "100%" gap = "50"
horizontalAlign = "center" verticalAlign = "middle">
<s:Label id = "lblHeader" text = "Complex Controls Demonstration"
fontSize = "40" color = "0x777777" styleName = "heading" />
<s:Panel id = "richTextEditorPanel" title = "Using RichTextEditor"
width = "500" height = "300">
<s:layout>
<s:VerticalLayout gap = "10" verticalAlign = "middle"
horizontalAlign = "center" />
</s:layout>
<mx:RichTextEditor id = "richTextEditor" title = "RichTextEditor"
width = "90%" height = "150"
borderAlpha = "0.15"
creationComplete = "richTextEditor.htmlText = richTextString;" />
<s:TextArea id = "richText" width = "90%" height = "50" />
<s:HGroup>
<s:Button label = "Show Plain Text"
click = "richText.text = richTextEditor.text;" />
<s:Button label = "Show HTML Markup"
click = "richText.text = richTextEditor.htmlText;" />
</s:HGroup>
</s:Panel>
</s:VGroup>
</s:BorderContainer>
</s:Application>
完成所有更改后,让我们像在Flex - 创建应用程序章节中一样,在正常模式下编译并运行应用程序。如果应用程序一切正常,它将产生以下结果:[ 在线试用 ]