开发者

How to get ContextMenuItem x and y coordinates

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜