New topic: Automatic Contextual Menu Handling
<http://forums.realsoftware.com/viewtopic.php?t=38382> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message kendoll Post subject: Automatic Contextual Menu HandlingPosted: Tue Mar 29, 2011 1:01 pm Joined: Mon Jul 17, 2006 10:39 am Posts: 1709 I just stumbled upon a handy tip for all of you who want to add contextual menus to your controls. If your contextual menu has the same function as an already existing menu item, use the menu item object directly! This saves you from dynamically creating a new menu item with the same properties, and from writing additional code to handle its action. For example, let's say you have a menu item "Foo" in your File menu, and you have already created the appropriate menu handler to make it work. To set up a contextual menu with this item in a control, all you need to do is implement its ConstructContextualMenu event so that the "Foo" MenuItem (which you have probably named FileFoo by default) is added, like so: Code:Event Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean base.Append(FileFoo) Return True End Function Note that there is no additional code necessary to handle the menu item. The appropriate menu handler is called automatically when the item is selected. This tip applies to menus displayed though PopUp() as well, in case ConstructContextualMenu does not fit your needs. _________________ Kenneth McCleary [email protected] Top JShaffer Post subject: Re: Automatic Contextual Menu HandlingPosted: Tue Mar 29, 2011 1:08 pm Joined: Fri Jan 23, 2009 9:18 am Posts: 66 Location: Summerfield, Florida But beware: http://www.realsoftwareblog.com/2011/03 ... lones.html Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
