1

Textfield () - マウスの右クリック メニューが表示されないようにする方法 (COPY、PASTE、SELECT ALL などのオプションを持つメニュー)。

4

4 に答える 4

1

カスタムInteractiveObject.contextMenuを試しましたか?

于 2009-02-23T11:50:56.623 に答える
1

fieldsselectableプロパティを false に設定します。

于 2009-02-23T12:00:05.743 に答える
1

FlashPlayer のデフォルト メニュー項目。

私の知る限り、基本的な FlashPlayer 項目 (設定と情報) を削除することはできません。

FlashPlayers 内蔵アイテム

コンパイル時に指定するか、コード内から指定することで、上位のもの (再生、一時停止など) を削除できます。

contextMenu.hideBuiltInItems();

またはグローバルコンテキスト内:

stage.showDefaultContextMenu = false; 

TextField 関連のメニュー項目

コピー/貼り付け/選択は、TextFields にも組み込まれているため、非表示にできないようです。ただし、本当にそれらを取り除きたいように見えるので、ここに回避策があります。次の例は、textField の上に透明なボタンを追加して、マウスの動作を回避する方法を示しています。

package  
{
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.ui.ContextMenu;        


    public class TestText extends Sprite 
    {

        private var textField:TextField;

        public function TestText()
        {
            // Removes the inbuit items from the contextMenu

            var contextMenu:ContextMenu = new ContextMenu();
            contextMenu.hideBuiltInItems();
            this.contextMenu = contextMenu;

            // Adds a simple input TextField

            textField = addChild(new TextField()) as TextField;
            textField.type = TextFieldType.INPUT;
            textField.text = "Test Text";

            // Covers the TextField with a transparent shape

            var shape:Sprite = addChild(new Sprite()) as Sprite;
            shape.graphics.beginFill(0, 0);
            shape.graphics.drawRect(0, 0, textField.width, textField.height);
            shape.mouseChildren = false;

            // Listens to a click on the mask to activate typing

            shape.addEventListener(MouseEvent.CLICK, eventClickHandler);
        }

        private function eventClickHandler(event:MouseEvent):void
        {
            // Sets the focus to the underlaying TextField and makes 
            // a full selection of the existing text.

            stage.focus = textField;
            textField.setSelection(0, textField.text.length);
        }
    }
}
于 2009-02-24T00:29:28.703 に答える
1

TextFieldsのデフォルトのコンテキスト メニュー項目を非表示にする方法を見つけました。

カスタム コンテキスト メニューを設定し、組み込みのアイテムを非表示にするだけです。右クリックしても何も起こりません!

 // hide cut/copy/paste
 var cm:ContextMenu = new ContextMenu();
 cm.hideBuiltInItems();
 textfield.contextMenu = cm;
于 2011-10-28T12:06:14.807 に答える