Implementing a right click menu
Posted: Thu Dec 11, 2008 3:28 pm
Has anyone implemented a right click menu before? There are a couple of posts here where people are trying to implement right click menus, but are having issues with no response. I think I have it working now, but it seems unintuitive, so I wanted to check if my assumptions are valid.
What I tried first:
- calling env->addContextMenu with parent set to 0. I would add my items and set the visibility to false. When I would right click, i would make the contextMenu visible and move it to the mouse position. This would cause crashes, as some internal gui behavior seemed to delete my context menu. If I added a grab when creating my menu, I could use my menu an additional time, then it would crash later. I would also lose the nice autosizing of the menu when setting the new position rectangle.
What I am doing now:
- I simply add the contextMenu whenever a user right clicks, and assume irrlicht is deleting them.
Does anyone know if this is reasonable or know the conditions that cause a contextMenu to be dropped?
What I tried first:
- calling env->addContextMenu with parent set to 0. I would add my items and set the visibility to false. When I would right click, i would make the contextMenu visible and move it to the mouse position. This would cause crashes, as some internal gui behavior seemed to delete my context menu. If I added a grab when creating my menu, I could use my menu an additional time, then it would crash later. I would also lose the nice autosizing of the menu when setting the new position rectangle.
What I am doing now:
- I simply add the contextMenu whenever a user right clicks, and assume irrlicht is deleting them.
Does anyone know if this is reasonable or know the conditions that cause a contextMenu to be dropped?