简体   繁体   English

Flex +图像+禁用拖动

[英]Flex + Image + Disable Drag

How do I diable the drag-drop of an image. 如何禁用图像的拖放。 I've tried to stopPropagation, but that didn't help. 我试图停止传播,但这没有帮助。

Here is the snippet of the code that I've written 这是我编写的代码的片段

<mx:Image width="24" height="24" complete="init()" dragStart="disableMove(event)" 
                                    source="{(data.id==null)?'': (data.id.search('\\.') > 0) ? 'assets/icons/teacher.png' : 'assets/icons/student.png'}" 
                                    toolTip="{data.data}" doubleClick="itemDoubleClick(event, data.id)" doubleClickEnabled="true">

                                    <mx:Script>
                                        <![CDATA[
                                            import mx.controls.Alert;
                                            import flash.events.MouseEvent;
                                            import flash.ui.ContextMenu;
                                            import flash.ui.ContextMenuItem;

                                            private var allCurrentItems: Array = new Array();

                                            private function itemDoubleClick(event: Event, id: String): void {
                                                Alert.show("Clicked = "+id);
                                            }

                                            private function init(): void {
                                                var menuLabel:String = "About School\u00A0";
                                                var cm:ContextMenu = new ContextMenu();

                                                cm.hideBuiltInItems();

                                                var item:ContextMenuItem = new ContextMenuItem(menuLabel);

                                                this.addEventListener(MouseEvent.MOUSE_DOWN, showClick);

                                                //add eventlisteners to the menu item and provide functions
                                                cm.customItems.push(item);
                                                //cm.customItems = [item];

                                                this.contextMenu = cm;
                                            }

                                            private function showClick(event:MouseEvent): void {
                                                if (event.buttonDown) {
                                                    Alert.show(String(event.buttonDown));
                                                }
                                            }

                                            private function disableMove(event: MouseEvent): void {
                                                event.stopImmediatePropagation();
                                            }
                                        ]]>
                                    </mx:Script>
                                </mx:Image>

我得到了它,而不是在dragStart()上调用disableMove(event),而是在它起作用的mouseDown()上调用了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM