开发者

How to get ContextMenuItem x and y coordinates

开发者 https://www.devze.com 2023-02-04 13:41 出处:网络
i build a contextmenu i want when user click any item then i get the x and y coordinate of the contextmenuitem............actullyiwant to dispaly a t开发者_高级运维extbox infornt of contextmenuitem wh

i build a contextmenu i want when user click any item then i get the x and y coordinate of the contextmenuitem............actully i want to dispaly a t开发者_高级运维extbox infornt of contextmenuitem when user click on the item........ or any other solution that i will show inputtext control as submenuitem in contextmenuitem


The only way I can think of doing what you are asking for is:

  • disallow the right-click mouse in the html container with javascript

  • capture right-click events and forward them to flash via ExternalInterface

  • In the method triggered from ExternalInterface, do/show what you want.

There are some open source solutions:

  • custom-context-menu
  • Article at ADM blog


Add an event listener to each menu item. In the listener function, the event's target object is the object you clicked on - all you need to do is cast it to DisplayObject, and you can access the x and y coordinates:

contextmenuItem.addEventListener (MouseEvent.CLICK, onItemClick);

function onItemClick (ev:MouseEvent) : void {
   var item:DisplayObject = ev.target as DisplayObject;
   // use item.x and item.y to get the object's position.
}
0

精彩评论

暂无评论...
验证码 换一张
取 消