MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / showMenu

Method showMenu

CodenameOne/src/com/codename1/ui/MenuBar.java:676–743  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

674 /// The method creates a Dialog with the commands and calls showMenuDialog.
675 /// The method blocks until the user dispose the dialog.
676 public void showMenu() {
677 final Dialog d = new Dialog("Menu", "");
678 d.setDisposeWhenPointerOutOfBounds(true);
679 d.setMenu(true);
680 d.addOrientationListener(new MenuDisposerActionListener(d));
681 d.setTransitionInAnimator(transitionIn);
682 d.setTransitionOutAnimator(transitionOut);
683 d.setLayout(new BorderLayout());
684 d.setScrollable(false);
685 //calling parent.createCommandComponent is done only for backward
686 //compatability reasons, in the next version this call be replaced with
687 //calling directly to createCommandComponent
688 d.getMenuBar().commandList = createCommandComponent(commands);
689 if (menuCellRenderer != null && d.getMenuBar().commandList instanceof List) {
690 ((List) d.getMenuBar().commandList).setListCellRenderer(menuCellRenderer);
691 }
692 d.getContentPane().getStyle().setMargin(0, 0, 0, 0);
693 d.addComponent(BorderLayout.CENTER, d.getMenuBar().commandList);
694 if (thirdSoftButton) {
695 d.addCommand(selectMenuItem);
696 d.addCommand(cancelMenuItem);
697 } else {
698 d.addCommand(cancelMenuItem);
699 if (soft.length > 1) {
700 d.addCommand(selectMenuItem);
701 }
702 }
703 d.setClearCommand(cancelMenuItem);
704 d.setBackCommand(cancelMenuItem);
705
706 if (d.getMenuBar().commandList instanceof List) {
707 ((List) d.getMenuBar().commandList).addActionListener(d.getMenuBar());
708 }
709 menuDisplaying = true;
710 Command result = showMenuDialog(d);
711 menuDisplaying = false;
712 if (result != cancelMenuItem) { //NOPMD CompareObjectsWithEquals
713 Command c = null;
714 if (result == selectMenuItem) { //NOPMD CompareObjectsWithEquals
715 c = getComponentSelectedCommand(d.getMenuBar().commandList);
716 if (c != null) {
717 ActionEvent e = new ActionEvent(c, ActionEvent.Type.Command);
718 c.actionPerformed(e);
719 }
720 } else {
721 c = result;
722 // a touch menu will always send its commands on its own...
723 if (!isTouchMenus() && c != null) {
724 ActionEvent e = new ActionEvent(c, ActionEvent.Type.Command);
725 c.actionPerformed(e);
726 }
727 }
728 // menu item was handled internally in a touch interface that is not a touch menu
729 if (c != null) {
730 parent.actionCommandImpl(c);
731 }
732 }
733 if (d.getMenuBar().commandList instanceof List) {

Callers 3

actionPerformedMethod · 0.95
keyReleasedMethod · 0.95
actionPerformedMethod · 0.80

Calls 15

setMenuMethod · 0.95
setLayoutMethod · 0.95
setScrollableMethod · 0.95
getContentPaneMethod · 0.95
addComponentMethod · 0.95
showMenuDialogMethod · 0.95
actionPerformedMethod · 0.95
isTouchMenusMethod · 0.95
getInstanceMethod · 0.95

Tested by

no test coverage detected