[flexcoders] Re: context menu in a datagrid in flex 4
Hi All, It worked . If we assign the context menu using the id of datagrid then the context menu works, for example if the id of datagrid is dg, then by using dg.contextmenu = cm. But I wonder why it doesn't work by assigning it directly in datagrid using binding. Thanks Nitin Gopi
[flexcoders] Re: Context Menu
Angelo According to the documentation at http://livedocs.adobe.com/flex/3/html/help.html?content=Menus_4.html - The primary drawback to using the context menu API is that it does not support submenus. But, there are other ways to skin a cat. Check these links out... http://code.google.com/p/custom-context-menu/ http://flexology.wordpress.com/2008/12/12/custom-right-click-contextmenu-in-flex/ I tried the code from the second link and it worked great. --- In flexcoders@yahoogroups.com, Angelo Anolin angelo_ano...@... wrote: Hi FlexCoders, Has anyone implemented a right mouse click context menu which contains sub-menu items? I have been able to create a datagrid control with right mouse menu and the context menu I have defined appears, but I have no idea on how to implement one which contains sub-menu. Any help/inputs would be appreciated. Thanks. Regards, Angelo
[flexcoders] Re: context menu event on tree column of advanced data grid ....
Solved this - added context menu within AdvancedDataGroupItemRenderer. --- In flexcoders@yahoogroups.com, MicC chigwel...@... wrote: When a context menu on an ADG is clicked and the ADG cell is not a hierarchy node, the ContextMenuEvent.mouseTarget is ADGItemRenderEX and info about the grid cell data clicked on to raise the context menu can be grabbed from ADGItemRendererEX.listData.Item. But when a node in the hierarchical column of an ADG is clicked to raise the context menu, the context menu ContextMenuEvent.mouseTarget is a AdvancedListBaseContentHolder . and does not seem to hold any info about the grid cell (hierarchy node). How do I extract info about the hierarchy node from AdvancedListBaseContentHolder? TIA, Mic.
[flexcoders] Re: Context Menu mouseTarget Issue
This worked: myCanvas.removeChildAt(myCanvas.getChildIndex(event.mouseTarget)); and myCanvas.removeChildAt(myCanvas.getChildIndex(event.mouseTarget.parent)); depending on whether the mouse is over the root Panel component or the child containers added to the panel. The harder part is identifying which item in my ArrayCollection corresponds to the mouseTarget. What I've ended up doing is capturing the parent/child path (E.g. TestApp0.canvasShell.myCanvas.myContainer592) in my ArrayCollection, then looping until I find a match and removing that item. Is there a more efficient way? --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: What is event.mouseTarget? and what is its parent? You might be off a level or two. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of jmfillman Sent: Tuesday, September 01, 2009 2:01 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Context Menu mouseTarget Issue I have a canvas container with several custom containers added to it. I have a context menu so that when you right click on the containers, you can remove it from the canvas container. When I go to remove a child, I get an error, below. Code: private function menuSelectHandler(event:ContextMenuEvent):void { var remChild:Number; var target:String = event.mouseTarget.toString(); trace (target); if (target.match(UIComponent) == null target.match(resizeBar) == null) { trace ( True 1); trace ( +event.mouseTarget); remChild = cal0Day.getChildIndex(event.mouseTarget); } else { trace ( True 2); trace ( +event.mouseTarget.parent); remChild = myCanvas.getChildIndex(event.mouseTarget.parent); } trace (remChild); trace (myCanvas.getChildAt(remChild)); myCanvas.removeChildAt(remChild); myAC.removeChildAt(remChild); updateLayout(); } TestApp0.canvasShell.myCanvas.myContainer592 True 1 TestApp0.canvasShell.myCanvas.myContainer592 12 TestApp0.canvasShell.myCanvas.myContainer592 Then I get the following error: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/getChildIndex() How do I do this?
RE: [flexcoders] Re: Context Menu mouseTarget Issue
You can try getObjectsUnderPoint (use mouseX/Y to get stage coordinates). Your custom container should be in the array it returns. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of jmfillman Sent: Wednesday, September 02, 2009 11:27 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Context Menu mouseTarget Issue This worked: myCanvas.removeChildAt(myCanvas.getChildIndex(event.mouseTarget)); and myCanvas.removeChildAt(myCanvas.getChildIndex(event.mouseTarget.parent)); depending on whether the mouse is over the root Panel component or the child containers added to the panel. The harder part is identifying which item in my ArrayCollection corresponds to the mouseTarget. What I've ended up doing is capturing the parent/child path (E.g. TestApp0.canvasShell.myCanvas.myContainer592) in my ArrayCollection, then looping until I find a match and removing that item. Is there a more efficient way? --- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, Alex Harui aha...@... wrote: What is event.mouseTarget? and what is its parent? You might be off a level or two. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com] On Behalf Of jmfillman Sent: Tuesday, September 01, 2009 2:01 PM To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Context Menu mouseTarget Issue I have a canvas container with several custom containers added to it. I have a context menu so that when you right click on the containers, you can remove it from the canvas container. When I go to remove a child, I get an error, below. Code: private function menuSelectHandler(event:ContextMenuEvent):void { var remChild:Number; var target:String = event.mouseTarget.toString(); trace (target); if (target.match(UIComponent) == null target.match(resizeBar) == null) { trace ( True 1); trace ( +event.mouseTarget); remChild = cal0Day.getChildIndex(event.mouseTarget); } else { trace ( True 2); trace ( +event.mouseTarget.parent); remChild = myCanvas.getChildIndex(event.mouseTarget.parent); } trace (remChild); trace (myCanvas.getChildAt(remChild)); myCanvas.removeChildAt(remChild); myAC.removeChildAt(remChild); updateLayout(); } TestApp0.canvasShell.myCanvas.myContainer592 True 1 TestApp0.canvasShell.myCanvas.myContainer592 12 TestApp0.canvasShell.myCanvas.myContainer592 Then I get the following error: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/getChildIndex() How do I do this?
[flexcoders] Re: Context Menu Bug in FlashPlayer ?
I did file a bug with Adobe. Hopefully it'll be addressed soon. Interesting that it was encountered in FlashPlayer 9. I don't recall which version of 9 I had, but I did not encounter this error until I went to FlashPlayer 10. For my application, it is critical that particular conectMenu items only appear when right-clicking on certain display items. Once the mouse moves off of the item, that custom item should no longer be available. If there is a better way to accomplish this, I would be very interested in exploring it. -JF --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: I think I know why it crashes (Although it should not crash the browser - it should fail with a Flash null object error. You should file a bug). When a right click event happens, a mouse out event happens first (Why? I don't know. Maybe this is a bug too) so your mouseOt function gets called which removes the context menu item. I assume, at this point, that the eventlistener is no longer valid but the event has already fired and is trying to find somewhere to go. This is what causes the crash. The moral of this is that you should not remove something willy nilly like this. First make sure you do not need it any more and then remove it. --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ wrote: Not here. I am still using Flash Player 9.0.124. --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: Thank you for the follow-up. The blankMenu is actually a left over from my actual application and wasn't needed for this sample code. This worked fine in FlashPlayer 9, so must be a bug with 10. JF --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ wrote: I tried your code and it crashes my browser here. I could not find a way to stop that behavior in my (Admittedly short) testing. The only thing that jumped out at me was that your blankMenu is a null object as it is never instantiated. Unfortunately, even if it is instantiated, the crashing continues. The one question I have is why you are assigning a blank menu on mouseout? There is no reason to do this. If the mouse is no longer over the button, there is no context menu. I would just ignore a mouseout entirely. If I get some more time I will have another look. Other that that, maybe someone else has a suggestion. Steve --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: Any suggestions? Am I doing something wrong? JF --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: The code below causes both IE and Firefox to crash (haven't tried others). The problem seems to occure when removing an item from a custom context menu. It doesn't even debug, just crashes the browser. If I add this one line: menu.customItems.pop(); then the browser crashes. If I remove it, if functions as expected. Please help. Sample code below: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.controls.Alert; [Bindable] public var menu:ContextMenu; [Bindable] public var blankMenu:ContextMenu; public function mouseOvr(event:MouseEvent):void { menu = new ContextMenu; var addPop:ContextMenuItem = new ContextMenuItem(Do Something); addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); menu.customItems.push(addPop); myButton.contextMenu = menu; } public function newPop (event:ContextMenuEvent):void { Alert.show(Hi); } public function mouseOt(event:MouseEvent):void { myButton.contextMenu = blankMenu; menu.customItems.pop(); } ]] /mx:Script mx:Button x=349 y=189 label=Button width=101 height=41 id=myButton mouseOver=mouseOvr(event) mouseOut=mouseOt(event)/ /mx:Application
[flexcoders] Re: Context Menu Bug in FlashPlayer ?
Not here. I am still using Flash Player 9.0.124. --- In flexcoders@yahoogroups.com, jmfillman jmfill...@... wrote: Thank you for the follow-up. The blankMenu is actually a left over from my actual application and wasn't needed for this sample code. This worked fine in FlashPlayer 9, so must be a bug with 10. JF --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ wrote: I tried your code and it crashes my browser here. I could not find a way to stop that behavior in my (Admittedly short) testing. The only thing that jumped out at me was that your blankMenu is a null object as it is never instantiated. Unfortunately, even if it is instantiated, the crashing continues. The one question I have is why you are assigning a blank menu on mouseout? There is no reason to do this. If the mouse is no longer over the button, there is no context menu. I would just ignore a mouseout entirely. If I get some more time I will have another look. Other that that, maybe someone else has a suggestion. Steve --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: Any suggestions? Am I doing something wrong? JF --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: The code below causes both IE and Firefox to crash (haven't tried others). The problem seems to occure when removing an item from a custom context menu. It doesn't even debug, just crashes the browser. If I add this one line: menu.customItems.pop(); then the browser crashes. If I remove it, if functions as expected. Please help. Sample code below: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.controls.Alert; [Bindable] public var menu:ContextMenu; [Bindable] public var blankMenu:ContextMenu; public function mouseOvr(event:MouseEvent):void { menu = new ContextMenu; var addPop:ContextMenuItem = new ContextMenuItem(Do Something); addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); menu.customItems.push(addPop); myButton.contextMenu = menu; } public function newPop (event:ContextMenuEvent):void { Alert.show(Hi); } public function mouseOt(event:MouseEvent):void { myButton.contextMenu = blankMenu; menu.customItems.pop(); } ]] /mx:Script mx:Button x=349 y=189 label=Button width=101 height=41 id=myButton mouseOver=mouseOvr(event) mouseOut=mouseOt(event)/ /mx:Application
[flexcoders] Re: Context Menu Bug in FlashPlayer ?
I think I know why it crashes (Although it should not crash the browser - it should fail with a Flash null object error. You should file a bug). When a right click event happens, a mouse out event happens first (Why? I don't know. Maybe this is a bug too) so your mouseOt function gets called which removes the context menu item. I assume, at this point, that the eventlistener is no longer valid but the event has already fired and is trying to find somewhere to go. This is what causes the crash. The moral of this is that you should not remove something willy nilly like this. First make sure you do not need it any more and then remove it. --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: Not here. I am still using Flash Player 9.0.124. --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: Thank you for the follow-up. The blankMenu is actually a left over from my actual application and wasn't needed for this sample code. This worked fine in FlashPlayer 9, so must be a bug with 10. JF --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ wrote: I tried your code and it crashes my browser here. I could not find a way to stop that behavior in my (Admittedly short) testing. The only thing that jumped out at me was that your blankMenu is a null object as it is never instantiated. Unfortunately, even if it is instantiated, the crashing continues. The one question I have is why you are assigning a blank menu on mouseout? There is no reason to do this. If the mouse is no longer over the button, there is no context menu. I would just ignore a mouseout entirely. If I get some more time I will have another look. Other that that, maybe someone else has a suggestion. Steve --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: Any suggestions? Am I doing something wrong? JF --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: The code below causes both IE and Firefox to crash (haven't tried others). The problem seems to occure when removing an item from a custom context menu. It doesn't even debug, just crashes the browser. If I add this one line: menu.customItems.pop(); then the browser crashes. If I remove it, if functions as expected. Please help. Sample code below: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.controls.Alert; [Bindable] public var menu:ContextMenu; [Bindable] public var blankMenu:ContextMenu; public function mouseOvr(event:MouseEvent):void { menu = new ContextMenu; var addPop:ContextMenuItem = new ContextMenuItem(Do Something); addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); menu.customItems.push(addPop); myButton.contextMenu = menu; } public function newPop (event:ContextMenuEvent):void { Alert.show(Hi); } public function mouseOt(event:MouseEvent):void { myButton.contextMenu = blankMenu; menu.customItems.pop(); } ]] /mx:Script mx:Button x=349 y=189 label=Button width=101 height=41 id=myButton mouseOver=mouseOvr(event) mouseOut=mouseOt(event)/ /mx:Application
[flexcoders] Re: Context Menu Bug in FlashPlayer ?
Thank you for the follow-up. The blankMenu is actually a left over from my actual application and wasn't needed for this sample code. This worked fine in FlashPlayer 9, so must be a bug with 10. JF --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: I tried your code and it crashes my browser here. I could not find a way to stop that behavior in my (Admittedly short) testing. The only thing that jumped out at me was that your blankMenu is a null object as it is never instantiated. Unfortunately, even if it is instantiated, the crashing continues. The one question I have is why you are assigning a blank menu on mouseout? There is no reason to do this. If the mouse is no longer over the button, there is no context menu. I would just ignore a mouseout entirely. If I get some more time I will have another look. Other that that, maybe someone else has a suggestion. Steve --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: Any suggestions? Am I doing something wrong? JF --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: The code below causes both IE and Firefox to crash (haven't tried others). The problem seems to occure when removing an item from a custom context menu. It doesn't even debug, just crashes the browser. If I add this one line: menu.customItems.pop(); then the browser crashes. If I remove it, if functions as expected. Please help. Sample code below: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.controls.Alert; [Bindable] public var menu:ContextMenu; [Bindable] public var blankMenu:ContextMenu; public function mouseOvr(event:MouseEvent):void { menu = new ContextMenu; var addPop:ContextMenuItem = new ContextMenuItem(Do Something); addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); menu.customItems.push(addPop); myButton.contextMenu = menu; } public function newPop (event:ContextMenuEvent):void { Alert.show(Hi); } public function mouseOt(event:MouseEvent):void { myButton.contextMenu = blankMenu; menu.customItems.pop(); } ]] /mx:Script mx:Button x=349 y=189 label=Button width=101 height=41 id=myButton mouseOver=mouseOvr(event) mouseOut=mouseOt(event)/ /mx:Application
[flexcoders] Re: Context Menu Bug in FlashPlayer ?
I tried your code and it crashes my browser here. I could not find a way to stop that behavior in my (Admittedly short) testing. The only thing that jumped out at me was that your blankMenu is a null object as it is never instantiated. Unfortunately, even if it is instantiated, the crashing continues. The one question I have is why you are assigning a blank menu on mouseout? There is no reason to do this. If the mouse is no longer over the button, there is no context menu. I would just ignore a mouseout entirely. If I get some more time I will have another look. Other that that, maybe someone else has a suggestion. Steve --- In flexcoders@yahoogroups.com, jmfillman jmfill...@... wrote: Any suggestions? Am I doing something wrong? JF --- In flexcoders@yahoogroups.com, jmfillman jmfillman@ wrote: The code below causes both IE and Firefox to crash (haven't tried others). The problem seems to occure when removing an item from a custom context menu. It doesn't even debug, just crashes the browser. If I add this one line: menu.customItems.pop(); then the browser crashes. If I remove it, if functions as expected. Please help. Sample code below: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.controls.Alert; [Bindable] public var menu:ContextMenu; [Bindable] public var blankMenu:ContextMenu; public function mouseOvr(event:MouseEvent):void { menu = new ContextMenu; var addPop:ContextMenuItem = new ContextMenuItem(Do Something); addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); menu.customItems.push(addPop); myButton.contextMenu = menu; } public function newPop (event:ContextMenuEvent):void { Alert.show(Hi); } public function mouseOt(event:MouseEvent):void { myButton.contextMenu = blankMenu; menu.customItems.pop(); } ]] /mx:Script mx:Button x=349 y=189 label=Button width=101 height=41 id=myButton mouseOver=mouseOvr(event) mouseOut=mouseOt(event)/ /mx:Application
[flexcoders] Re: Context Menu Bug in FlashPlayer ?
Any suggestions? Am I doing something wrong? JF --- In flexcoders@yahoogroups.com, jmfillman jmfill...@... wrote: The code below causes both IE and Firefox to crash (haven't tried others). The problem seems to occure when removing an item from a custom context menu. It doesn't even debug, just crashes the browser. If I add this one line: menu.customItems.pop(); then the browser crashes. If I remove it, if functions as expected. Please help. Sample code below: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.controls.Alert; [Bindable] public var menu:ContextMenu; [Bindable] public var blankMenu:ContextMenu; public function mouseOvr(event:MouseEvent):void { menu = new ContextMenu; var addPop:ContextMenuItem = new ContextMenuItem(Do Something); addPop.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newPop); menu.customItems.push(addPop); myButton.contextMenu = menu; } public function newPop (event:ContextMenuEvent):void { Alert.show(Hi); } public function mouseOt(event:MouseEvent):void { myButton.contextMenu = blankMenu; menu.customItems.pop(); } ]] /mx:Script mx:Button x=349 y=189 label=Button width=101 height=41 id=myButton mouseOver=mouseOvr(event) mouseOut=mouseOt(event)/ /mx:Application
[flexcoders] Re: Context menu triggers browser crash
You might try running the same behavior from a simple button, instead of from a context menu, since that might give you a sense of where the problem lies: i.e. if it occurs even when you run the behavior off a button, then the problem presumably has nothing to do with the context menu. --- In flexcoders@yahoogroups.com, Guy Morton [EMAIL PROTECTED] wrote: Hi there I have a Flex 2 app that has a custom context menu attached to the root application object. It works without incident on the Mac, but on windows, choosing an item from the context menu sometimes causes the browser to crash. There appears to be no pattern to it, though it does seem to occur more frequently when choosing a menu item that calls a function that does a couple of sequential HTTP requests and thus can take a little while (maybe a second or two) to complete. This happens in both IE and Firefox on windows, so for once we can't just blame IE. :-) Anyone seen this behaviour before and know what causes it, or how to work around it? TIA Guy
Re: [flexcoders] Re: Context menu
You can't get rid of those two (limitation of the player). - Daniel Freiman On Sat, Jun 21, 2008 at 8:01 PM, markgoldin_2000 [EMAIL PROTECTED] wrote: I am using this: var menu:ContextMenu = new ContextMenu(); menu.hideBuiltInItems(); but when I run my program and click on a cell with the right mouse I have my items alone with standard Settings, About ... items. --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: hideBuiltInItems From: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com flexcoders%40yahoogroups.com] On Behalf Of markgoldin_2000 Sent: Saturday, June 21, 2008 1:08 PM To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com Subject: [flexcoders] Context menu How can I remove all builtin items? Thanks
[flexcoders] Re: Context menu
I am using this: var menu:ContextMenu = new ContextMenu(); menu.hideBuiltInItems(); but when I run my program and click on a cell with the right mouse I have my items alone with standard Settings, About ... items. --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: hideBuiltInItems From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of markgoldin_2000 Sent: Saturday, June 21, 2008 1:08 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Context menu How can I remove all builtin items? Thanks
[flexcoders] Re: Context Menu Use in PopUp
Well, yes. The menuItem has an event listener in the parent application that calls a function. I solved it. --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: By functions do you mean event listeners? How are you setting it up? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jmfillman Sent: Friday, June 13, 2008 10:14 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Context Menu Use in PopUp I have a ContextMenu in my parent application. I can make the same ContextMenu show in a popup titleWindow, however, the functions do not fire when clicked in the popup. How can I do this?
[flexcoders] Re: Context menu in flex
A little examplecode: Start of code //creates a new entry in the contextMenu // which is handled by the (self-written) function doMyCommand(Event) var myCMI:ContextMenuItem; myCMI = new ContextMenuItem(myMenuCommand); myCMI.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doMyCommand); this.treeComponentID.contextMenu.customItems.push(myCMI); End of Code Check the livedocs for ContextMenu(Item) to disable most of the built-in items. Also, keep in mind that your menuItem can't be named the same as one of the Items used by the Flashplayer (like: copy, delete, ...) --jeetee --- In flexcoders@yahoogroups.com, yourName [EMAIL PROTECTED] wrote: Hi iam new to this group and working with flex about one month. I want to add custom contex menu in tree component any one can help me or can send a code sample can i display popup menu when some one right clicks on my tree menu. Thanks in advance
[flexcoders] Re: Context menu mouseTarget vs. itemRenderer with Image control
If you are using a custom item renderer why aren't you just adding the context menu to the item renderer? As a note if you are extending one of the default item renderers they have the mouse disabled in the constructor so this needs to be fixed. --- In flexcoders@yahoogroups.com, tsiesser [EMAIL PROTECTED] wrote: I'm hoping someone's had experience with this one... I have a TileList control with a custom itemRenderer. The renderer consists of an Image control and a few Label controls. I've also attached a custom context menu to the TileList. In the MENU_SELECT event, I want to set the TileList's selectedItem to the item that the mouse is over before popping up the context menu. So I examine the event.mouseTarget property... this might be one of the embedded Label controls, so I crawl up the parent property till I get to the top. Works great - I eventually get to the itemRenderer level, where I can check if the renderer.data value is already selected, and if not, select it. It *doesn't* work if I right-click on the Image control. In that case, mouseTarget comes back as a MovieClip object with its parent property set to null - there doesn't seem to be any way to determine which itemRenderer it belongs to! Any ideas? All help appreciated, as always!!! --Tracey
[flexcoders] Re: Context menu mouseTarget vs. itemRenderer with Image control
Wow - images are not mouse targets. Okay, that's going to be challenging - because I was actually planning on some special actions to occur when the user clicked on the corners of the image. So maybe the transparent sprite will be the key? I'll try it... Thanks! --Tracey --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: Images are not mouse targets. Try setting mouseChildren=true and/or mouseEnabled=true in the renderer. You may also need to cover the image with a Sprite with alpha=0 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of tsiesser Sent: Friday, June 01, 2007 4:59 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Context menu mouseTarget vs. itemRenderer with Image control I'm hoping someone's had experience with this one... I have a TileList control with a custom itemRenderer. The renderer consists of an Image control and a few Label controls. I've also attached a custom context menu to the TileList. In the MENU_SELECT event, I want to set the TileList's selectedItem to the item that the mouse is over before popping up the context menu. So I examine the event.mouseTarget property... this might be one of the embedded Label controls, so I crawl up the parent property till I get to the top. Works great - I eventually get to the itemRenderer level, where I can check if the renderer.data value is already selected, and if not, select it. It *doesn't* work if I right-click on the Image control. In that case, mouseTarget comes back as a MovieClip object with its parent property set to null - there doesn't seem to be any way to determine which itemRenderer it belongs to! Any ideas? All help appreciated, as always!!! --Tracey
[flexcoders] Re: Context menu mouseTarget vs. itemRenderer with Image control
It occurred to me to try adding the context menu to the item renderer, but I wasn't sure what would happen to the blank areas of the TileList, like if there aren't enough data items to fill the entire space... does the list get item renderers with data=null, or are there only renderers where there's actually data? (Trial and error would answer that, I guess...) I do still need the individual components of the item renderer to be separately clickable - as I mentioned in another reply, I want to do something special when the user clicks on the corner of the embedded image controls. Thanks for your help! More experimentation to come... --Tracey --- In flexcoders@yahoogroups.com, andrewalderson650 [EMAIL PROTECTED] wrote: If you are using a custom item renderer why aren't you just adding the context menu to the item renderer? As a note if you are extending one of the default item renderers they have the mouse disabled in the constructor so this needs to be fixed. --- In flexcoders@yahoogroups.com, tsiesser tsiesser@ wrote: I'm hoping someone's had experience with this one... I have a TileList control with a custom itemRenderer. The renderer consists of an Image control and a few Label controls. I've also attached a custom context menu to the TileList. In the MENU_SELECT event, I want to set the TileList's selectedItem to the item that the mouse is over before popping up the context menu. So I examine the event.mouseTarget property... this might be one of the embedded Label controls, so I crawl up the parent property till I get to the top. Works great - I eventually get to the itemRenderer level, where I can check if the renderer.data value is already selected, and if not, select it. It *doesn't* work if I right-click on the Image control. In that case, mouseTarget comes back as a MovieClip object with its parent property set to null - there doesn't seem to be any way to determine which itemRenderer it belongs to! Any ideas? All help appreciated, as always!!! --Tracey
RE: [flexcoders] Re: Context menu mouseTarget vs. itemRenderer with Image control
To be precise, mx:Image can be a mouseTarget as it is a UIComponent wrapping the images. Embedded images generally are not as are any other bitmaps loaded through flash.display.Loader. It depends on how you set things up. However, placing transparent hit areas is a good way to divide up areas of a renderer into separate targets. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of tsiesser Sent: Saturday, June 02, 2007 9:32 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Context menu mouseTarget vs. itemRenderer with Image control Wow - images are not mouse targets. Okay, that's going to be challenging - because I was actually planning on some special actions to occur when the user clicked on the corners of the image. So maybe the transparent sprite will be the key? I'll try it... Thanks! --Tracey --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui [EMAIL PROTECTED] wrote: Images are not mouse targets. Try setting mouseChildren=true and/or mouseEnabled=true in the renderer. You may also need to cover the image with a Sprite with alpha=0 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of tsiesser Sent: Friday, June 01, 2007 4:59 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Context menu mouseTarget vs. itemRenderer with Image control I'm hoping someone's had experience with this one... I have a TileList control with a custom itemRenderer. The renderer consists of an Image control and a few Label controls. I've also attached a custom context menu to the TileList. In the MENU_SELECT event, I want to set the TileList's selectedItem to the item that the mouse is over before popping up the context menu. So I examine the event.mouseTarget property... this might be one of the embedded Label controls, so I crawl up the parent property till I get to the top. Works great - I eventually get to the itemRenderer level, where I can check if the renderer.data value is already selected, and if not, select it. It *doesn't* work if I right-click on the Image control. In that case, mouseTarget comes back as a MovieClip object with its parent property set to null - there doesn't seem to be any way to determine which itemRenderer it belongs to! Any ideas? All help appreciated, as always!!! --Tracey
[flexcoders] Re: Context menu with custom cursor
I've currently worked around this issue by punching a small hole at the registration point of the cursor movieclip. This allows the mouse click to pass through to whatever is directly underneath the cursor. My theory is that the cursor movieclip is not a descendant of the application instance on the display list, so it is not using the Application context menu (I set the menu on the Application instance). Is there a _root equivalent where I can set the context menu? I know the stage cannot have a context menu applied, and I cant think of anything else. I'm going to go with this for now, but if anyone knows a better solution, please let me know. Thanks again, David --- In flexcoders@yahoogroups.com, davcavs [EMAIL PROTECTED] wrote: Hi, In my Flex 2 application I have a custom context menu, and I occasionally set a custom cursor. When the user right-clicks when the custom cursor is set, the default context menu is shown, not the custom context menu. This seems to only happen when the custom cursor exists under the mouse coordinates. The problem can be seen on this page: http://www.adobe.com/devnet/flex/quickstart/controlling_the_cursor/ On examples on that page, if you set the busy cursor, notice you get the default context menu. When you set the custom hourglass cursor, you don't, presumably because it is offset away from the mouse coordinates. In my app, the custom cursor exists under mouse coordinates, and like I said, the default menu is shown. The cursor I am using is embedded from a Flash 9 SWF, and in the class definition for the symbol, I have tried changing the contextMenu and disabling mouseEnabled, to no avail. Since my custom cursor is a magnifying glass, I really don't want Zoom In/Zoom Out on the context menu. Am I missing something? Has anyone overcome this? Thanks, David -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
[flexcoders] Re: context-menu in flex...
Hi everyone, I don't want to hijack this thread but it reminded me about one problem I had with the context menu. Does anyone knows a way to put a check before an item in the context menu ? Flash Player can do it (see Play and loop entries). I could not find anything in the ContextMenu Class. Thanks, Cristian --- In flexcoders@yahoogroups.com, Jeff Tapper [EMAIL PROTECTED] wrote: I've always dealt with leaving the miniumum information in the context menu, since the items you add appear first. Also, if you use the hideBuiltInItems() method, there are only 4 built in items which appear with what you add. At 10:57 AM 6/13/2006, you wrote: Hi everyone, OK, I really need to have a right click context menu coming up in a tree - either my own or the Flash one. It seems the Flash one cannot be done without some other stuff in it that we do not want. Has anyone found a way to maybe fake it so that the built in one does not come up? All the reading I have found on the subject involved previous versions of the player or involved bringing up other Alerts and stuff, but not a context menu. I have considered maybe bringing up a context menu upon double clicking on a line in the tree - but that is just not the way these interfaces would normally work. I am trying to simulate sort of an explorer type action on files in a tree. Hightlight an item, then right click to do copy, paste, delete etc. Any ideas? Thanks Jonathan On 4/24/06, Matt Chotin mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Look for the ContextMenu class in the ASDoc (and reference). You can't disable the right-click menu completely, the most you can do is remove some of the settings. Matt -Original Message- From: mailto:flexcoders@yahoogroups.comflexcoders@yahoogroups.com [mailto: [EMAIL PROTECTED] On Behalf Of Rajni Sent: Monday, April 24, 2006 8:03 PM To: mailto:flexcoders@yahoogroups.comflexcoders@yahoogroups.com Subject: [flexcoders] context-menu in flex... Hi, Can anybody tell me that how to customize the context-menu in flex? or how to disable right-click menu in flex? Thanks -Rajni -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txthttp://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comhttp://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txthttp://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comhttp://www.mail-archive.com/flexcoders%40yahoogroups.com -- YAHOO! GROUPS LINKS Visit your group http://groups.yahoo.com/group/flexcodersflexcoders on the web. To unsubscribe from this group, send an email to: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the http://docs.yahoo.com/info/terms/Yahoo! Terms of Service . -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.1.394 / Virus Database: 268.8.3/362 - Release Date: 6/12/2006 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.394 / Virus Database: 268.8.3/362 - Release Date: 6/12/2006 Yahoo! Groups Sponsor ~-- See what's inside the new Yahoo! Groups email. http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/nhFolB/TM ~- -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/