1/31/2024 0 Comments For mac instal Custom Context Menu![]() ![]() The main reason that right mouse button callbacks are there is for coders to use them for other than a context menu. ![]() In actuality, the #getMenu method returns and then the context menu is displayed by the SketchUp core.) (Also keep in mind that the context menu code appears to act in an asynchronous manner. You’d have to test if onRButtonUp also fires, and whether it fires before or after the context menu displays. (I know there are also some key down callbacks that never fire on MS Windows.) ![]() Well I think that your main confusion was caused by the bug that onRButtomDown does not (or did not) fire on Mac. methods in the Tool are ignored because the Sketchup engine ‘gets there first’ and activates getMenu(menu) ? You’d need to test.Ī question might be, which happens first the context menu display or the right mouse click callback ?Īnd that when either of those methods IS defined, and getMenu(menu) is also defined, the onRButton. I do not know if the SketchUp engine would both display the native context menu (in the absence of a getMenu method,) and also process a right mouse click callback. To do tasks only after menu items were chosen, then task method calls would need to be inserted into the menu item command blocks wherever desired. (This task would get done even if no menu item was chosen and the user ESCaped from the menu.) If a coder would want to always do some task before displaying a custom context menu, then they’d call a custom task method at the beginning of the getMenu callback. (Use the 'up" event because historically the onRButtonDown didn’t fire on some platforms or OSes.) Then (2) they’d define a onRButtonUp callback method that does something else. (Remember that if you do not define the getMenu method, then the SketchUp engine will display the native context menu.) If a coder would want something other than a context menu to happen upon right mouse click, then they’d need to (1) define an empty getMenu method so that no context menu appears. The SketchUp engine calls it when the context mouse button is clicked if the getMenu method is defined. You do not explicitly call this method from any other method especially mouseclick callback methods. Why did it work at all, and where did SU 2018 get the menu object ID which it passes to the getMenu(menu) method? (We entered some test code to show that the receiving function was given a Menu object and ID.)Įven if we don’t find out how it worked in SU 2018, how can we provide a menu object ID to the onRButtonDown (or …Up) event so the menu will work in SU 2019? Just use something likeĪt least that doesn’t error when I try it in the Ruby console, and returns:Īnd anyway, how does a context menu get triggered when you click on empty space in the model window?ĪFAIK, context menus usually need an object to click on, to provide a suitable context.Īgain, a tool or any other code does not call the getMenu callback method. Here’s what it pops up, when I replace the method in the tool with this simplified version. ![]() Here’s a simplified version of the getMenu(menu) method, with fixed text replacing the array values, and just with a fixed item in the menu shown as MF_CHECKED. Somehow, SU2018 fills in a valid Menu object ID and the menu works fine. Neither of us can work out why this worked at all - the getmenu() call has no menu parameter which the getMenu(menu) method requires, and in SU 2019 it immediately throws a mismatched number of arguments: 1 required, 0 supplied error (or words to that effect). I’m working again with Steve Baumgartner ( to rework the code, and we are trying to replicate this behaviour in SU 2019. # Load plugin-specific R-click context menu It was called by a simple onRButtonDown method within the Tool code. The content was defined in a method def getMenu(menu).end using information from arrays defined earlier in the code. Some years ago I developed a tool which (more or less) worked in SU 20.Ī R-click anywhere the drawing window (even in an empty part of it) would pop up a ‘context’ menu looking like this, from which to choose a softwood size before drawing a length of: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |