How can I use "createPopupMenu" to create a right click Menu
-
first,I already get sketchup handle "hMainwnd",then I want to create a right-click menu:
#---------
def AddPopupMenu(hMainwnd,x,y)
createPopupMenu = Win32API.new('user32.dll', 'CreatePopupMenu','', 'l')
appendMenu = Win32API.new('user32.dll', 'AppendMenu','liip', 'b')
clientToScreen = Win32API.new('user32.dll', 'ClientToScreen','lp', 'b')
trackPopupMenu = Win32API.new('user32.dll', 'TrackPopupMenu','liiiilp', 'b')# point = [0,0] hMenu = createPopupMenu.call appendMenu.call(hMenu,0x00000000,200,"Move") #clientToScreen.call(hMainwnd,point) trackPopupMenu.call(hMenu,2,x,y,0,hMainwnd,nil)
end
def onRButtonUp(flags, x, y, view)
hMwnd = GetSketchupWmd()
AddPopupMenu(hMwnd,x,y)
end
#--------------------------
but,when I right_click,Nothing happened on my sketchup!I don't know if this method is right or wrong. -
another way, I want to create a new context menu and Make it appear with sketchup context_menu at the same time .I already tried "getmenu" function,but it's just sketchup context_menu.
anybody know ? -
@season_x said:
... I want to create a right-click menu:
What do you want to create a context menu for ?
(There needs to be a context ... ie, something selected, or nothing selected, or a certain tool is active, etc.)Then you will wish to insert menu items onto the context menu. What kind of command(s) ?
SketchUp's Ruby API already has this feature available, so you need to work WITH the API as it exposes SketchUp's native context menu handler.
You cannot just brute force try to stomp over the native handler!
-
If I add common tools to the menu, They will make it too long,So I wanted to create a side-by-side menu ,so it wouldn't look too long.You know there are a lot of common tools,Their keyboard shortcuts were hard to remember,Many good software programs have a rich right - click menu,Clearly separated, not mixed.I believe that sketchup in the future will incorporate full screen capabilities,I'm a programmer and a designer, and I want to bulid model quickly,I think Right - click menus are more important than toolbars and shortcut key.Those are my reasons.Customizing personalized functional menus is also convenient and fun, isn't it?
-
You can use the API to add submenus to the context-menu,
Then each related set of entries only occupy one submenu item.
You can even nest even submenus...Also because it is a context-menu you can set up its items to only be shown in the list if a certain context applies - e.g. only if the selection contains faces offer some face related tools, or if the selection is just one section-plane then offer some special section-plane related tools...
-
@season_x said:
I think Right - click menus are more important than toolbars and shortcut key.
Doug Olivier (formerly a Trimble employee) is working on a popup button matrix called GhostMenu:
There is a beta version available to test. https://app.ghost.menu/
It uses a keyboard shortcut to popup the GhostMenu.
(But I cobbled up a little script to insert a command for GhostMenu into the top of SketchUp's context menu.)
Advertisement