Just like my subject, I want popup a menu when the user right click some item on my
I know the table can add a Mouse Listener,but there two things need be known,
first: left click or right click, second: which table item has been selected.
You have TableListBoxModel implemented on your one of the component, right ?
Then you just need to implement It’s
virtual void cellClicked (int rowNumber, int columnId, const MouseEvent & e) callback method, which will be called whenever any mouse click is detected on your particular cellItem,
create one PopupMenu * yourMenu ; in your component class, initialize in constructor with
yourMenu = new PopupMenu ();
// you can add menuItems either here or if you want dynamic following will help
1)it has rowNumber so you know which cell is selected currently .
2) you have MouseEvent & e here so use following
void cellClicked (int rowNumber, int columnId, const MouseEvent & e)
// for popup menu’s item selection use result
int result = 0;
// do stuff for left mouse click
// do stuff for right mouse click
// clear the menu if you want it dynamic every time
result = rightClickMenu->show();
if(result != 0)
if(result == 1)
// do for yourItem1
else if(result == 2)
// do for yourItem2
Good idea,I’ve solved it by your way,thanks.