Implementing a right click menu

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Implementing a right click menu

Post by drewbacca »

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?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I suggest you take a peek at the source for CGUIContextMenu.cpp. It should take less than 30 seconds to find out what conditions will cause the menu to be dropped (i.e. a call to remove()). I will admit that the behavior might be a little weird, but I can't say that it is really incorrect.

Travis
Post Reply