Flex component development Summary (aierong Original Technology essay)

Source: Internet
Author: User

1. How to listen to Keyboard Events?

<Mx: textarea id = "texteditor" keydown = "sendkeyhandler (event)" x = "11" Y = "366" width = "399"/>

Private function sendkeyhandler (EVT: keyboardevent): void
{

// Enter

If (EVT. keycode = 13)
{
This. sendtxt ();

Return;
}

}

CodeNote: There are two types of Keyboard Events:Keyboardevent. key_downAndKeyboardevent. key_up

The above is a carriage return event.

To listen for a combination of keys, for example, CTRL + enter, the Code is as follows:

If (EVT. keycode = 13 & EVT. ctrlkey)
{
}

2. How to control the control bar of richtexteditor?

Use the showcontrolbar attribute to control the control bar of richtexteditor, so that the entire control bar is closed.

You can refer to the following code to control the host controls in the control bar:

This. texteditor. alignbuttons. Height = 0;
This. texteditor. alignbuttons. Visible = false;

This. texteditor. bulletbutton. Height = 0;
This. texteditor. bulletbutton. Visible = false;

This. texteditor. linktextinput. Height = 0;
This. texteditor. linktextinput. Visible = false;

This. texteditor. _ richtexteditor_vrule1.height = 0;
This. texteditor. _ richtexteditor_vrule1.visible = false;

This. texteditor. _ richtexteditor_vrule2.height = 0;
This. texteditor. _ richtexteditor_vrule2.visible = false;

Of course, you can also refer to thisArticle

Http://blog.minidx.com/2008/12/29/1841.html

3. Why is the double-click event of the control unresponsive?

<Mx: button doubleclickenabled = "true" DoubleClick = "doubleclickhandler (event)" x = "48" Y = "32" label = "button"/>

Private function doubleclickhandler (EVT: mouseevent): void
{
Alert. Show ("DoubleClick ");
}

Code Description:

Doubleclickenabled attribute: Specifies whether the object receivesDoubleClickEvent. The default value isFalse, Which means that by default, do not receiveDoubleClickEvent. IfDoubleclickenabledSet propertyTrue, The instance receivesDoubleClickEvent

4. How can I insert characters at the cursor position of textarea?

<Mx: textarea id = "texteditor" x = "11" Y = "366" width = "399"/>

Private function insertstring (insertstr: string): void
{
If (this. texteditor. selectionbeginindex = This. texteditor. selectionendindex)
{
VaR startpart: String = This. texteditor. Text. substring (0, this. texteditor. selectionbeginindex );
VaR endpart: String = This. texteditor. Text. substring (this. texteditor. selectionendindex, this. texteditor. Text. Length );
Startpart + = insertstr;
Startpart + = endpart;
This. texteditor. Text = startpart;
}
Else
{
This. texteditor. Text = insertstr;
}
}

5. Is the scroll bar of the textarea Control always kept at the bottom?

This.txt _ content. addeventlistener (flexevent. value_commit, value_commithandler );
Private function value_commithandler (EVT: flexevent): void {
Txt_content.verticalscrollposition = txt_content.maxverticalscrollposition;
}

Code Description: This code is used to keep the scroll bar of the textarea control at the bottom to help you view chat information.

If the vbox control needs to achieve similar results, you can see the following code:

<Mx: vbox id = "VD" updatecomplete = "updatecompletehandler (event)" x = "10" Y = "10" width = "399" Height = "348">

Private function updatecompletehandler (EVT: flexevent): void
{
This. VD. verticalscrollposition = This. VD. maxverticalscrollposition;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.