From: SourceForge.net <no...@so...> - 2012-03-30 14:35:52
|
Support Requests item #3513124, was opened at 2012-03-30 00:48 Message generated for change (Comment added) made by miesfeld You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684731&aid=3513124&group_id=119701 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: ooDialog Group: Windows Status: Open Priority: 5 Private: No Submitted By: hakan (hexit34) >Assigned to: Mark Miesfeld (miesfeld) Summary: OODialog 4.2 treeview mouse right click Initial Comment: In a treeview it's possible to select an item with a left click on the mouse without programcode but is it possible to change selection (hilight an item) with a right click on the mouse, with programcode. If using a contextmenu it would be more "windows" like to right click an item that is not highlighted and get it selected, instead of first left click and then right click, to get the contextmenu. Thanks ---------------------------------------------------------------------- >Comment By: Mark Miesfeld (miesfeld) Date: 2012-03-30 07:35 Message: The simple answer is that yes it is possible. In general what you want to do is, in the event handler for the context event, determine which item, if any, is under the mouse and then select it before you show the context menu. Here is some sample code. This is ooDialog 4.2.0 code. What I did was grab some code from the ContextMenu.rex example and put it into the oodTree.rex example. Sort of a hack, but I think enough to give you the idea: ::method onDialogContext expose contextMenu use arg hwnd, x, y say 'In onDialogContext x:' x 'y:' y if x == -1, y == -1 then do -- The keyboard was used, not the mouse. This is a quick hack, just -- position the menu where ever the mouse is, i.e., do nothing nop end else do tree = self~newTreeView(IDC_TREE) -- Get mouse position and convert to client co-ordinates of tree view. hitPos = .Point~new(x, y) tree~screen2client(hitPos) -- Test the position info = tree~hitTestInfo(hitPos) say 'info hItem: ' info~hItem say 'info location:' info~location -- If on an item, select that item, otherwise do nothing if info~location~pos('ONITEM') <> 0 & info~hItem <> 0 then do tree~select(info~hItem) end end -- This is the point where the context menu is positioned. pos = .Point~new(x, y) -- Show the context menu ret = contextMenu~show(pos, self) if ret == -1 then do say 'contextMenu~show() failed SystemErrorCode:' || - .SystemErrorCode SysGetErrortext(.SystemErrorCode) end The above doesn't show the context menu creation or event connections, but you should be able to figure those out by looking at ContextMenu.rex. I tested it and it works. If you right click on an item in the tree view, it gets selected. If you right click on the tree view but on the tree view background, the selection remains what it was before you right clicked. If you have any questions or problems implementing this, let me know. Also, you may want to subscribe to the ooRexx User list, I answer any ooDialog questions pretty promptly on the list. The list is low volume and easy to monitor. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684731&aid=3513124&group_id=119701 |