Page 1 of 1

--Using popup menus

PostPosted: Tue Oct 01, 2013 3:44 pm
by Development@SIB


This article is outdated - please use our new system at

https://doc.sibvisions.com




If you need a popup menu for your table on right mouse click, simple add it. A short example:

Syntax: [ Download ] [ Hide ]
UIMenu menActions = new UIMenu("Actions");
                       
UIMenuItem miInsert = new UIMenuItem("Insert");
UIMenuItem miDelete = new UIMenuItem("Delete");
                       
menActions.add(miInsert);
menActions.add(miDelete);              
       
UIMenuItem  miSearch = new UIMenuItem("Show");
miSearch.setImage(UIImage.getImage(UIImage.SEARCH_SMALL));

UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.add(menActions);
popupMenu.addSeparator();
popupMenu.add(miSearch);

You should add a mouse event for your component, to show the popup (you also could add the event to an image or a panel):

Syntax: [ Download ] [ Hide ]
tblMaster.eventMousePressed().addListener(this, "doShowPopup");
 

and the listener method:

Syntax: [ Download ] [ Hide ]
public void doShowPopup(UIMouseEvent pEvent)
{
    if (pEvent.isPopupTrigger() )
    {  
        popupMenu.show(pEvent.getSource(), pEvent.getX(), pEvent.getY());
    }
}