How to popup menu on TableListBox when right click?


Hi All,
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.


Hey Bolt,

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
}else if(e.mods.isRightButtonDown())
// do stuff for right mouse click
// clear the menu if you want it dynamic every time
yourMenu ->clear();
yourMenu ->addItem(1,“yourItem1”,true);
yourMenu ->addItem(1,“yourItem2”,true);
result = rightClickMenu->show();

if(result != 0)
if(result == 1)
// do for yourItem1
else if(result == 2)
// do for yourItem2

Have Fun… :slight_smile:


Hey acn,
Good idea,I’ve solved it by your way,thanks.