New topic: ListBox Context Menu
<http://forums.realsoftware.com/viewtopic.php?t=30509> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message wee_eric Post subject: ListBox Context MenuPosted: Thu Oct 15, 2009 8:33 pm Joined: Fri Jan 11, 2008 6:33 am Posts: 101 Hi I have a multiline selection ListBox that I have added a context menu to. I want the context menu to perform a task on the selected entries of the ListBox. The problem is that when the user right clicks the ListBox to get the context menu, the selection is removed. Is there a way of retaining the selection while the right click happens? thanks Top DaveS Post subject: Re: ListBox Context MenuPosted: Thu Oct 15, 2009 9:04 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 1662 Location: San Diego, CA listbox1.listindex should still contain the value _________________ Dave Sisemore MacPro, OSX 10.5.8 RB2009r2 Top timhare Post subject: Re: ListBox Context MenuPosted: Fri Oct 16, 2009 1:24 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 6571 Location: Portland, OR USA This is a known bug. When you have multiple rows selected and contextual click, it deselects all but ListIndex. One workaround is to handle the contextual menu directly in MouseDown, using a MenuItem and its Popup method, and then return true out of MouseDown. It would be something like Code:dim base as New MenuItem if IsContextualClick then base.Append New MenuItem("item 1") base.Append New MenuItem("item 2") ... dim hitItem as MenuItem = base.Popup if hitItem = nil then return true select case hitItem.Text ... end return True end You could create a ListBox subclass and call the CreateContextualMenu and ContextualMenuAction events from MouseDown, so you can still use those events in your listbox instance. Code:dim base as New MenuItem if IsContextualClick then if ConstructContextualMenu(base) then dim hitItem as MenuItem = base.Popup if hitItem <> nil then call ContextualMenuAction end return true end Tim Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 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]
