Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid context menu breaks page dimensions

    Hi Isomorphic,

    can you add a sample with a ListGrid + long context menu?
    I'm doing menus like this:

    Code:
                    addRowContextClickHandler(new RowContextClickHandler() {
                        @Override
                        public void onRowContextClick(RowContextClickEvent event) {
                            event.cancel();
                            final ListGridRecord[] records = getSelectedRecords();
                            if (records.length == 1) {
                                Menu menu = new Menu();
                                menu.addItemClickHandler(new ItemClickHandler() {
                                    @Override
                                    public void onItemClick(ItemClickEvent event) {
                                    //...
                                    //...
                                    //...
                                    //...
                                    }
                                });
                                menu.setItems([B]....many items...[/B]);
                                menu.[B]setLeft(event.getX());[/B]
                                menu.[B]setTop(event.getY());[/B]
                                menu.draw();
                            }
                        }
                    });
    in order to display the menu at the click position, there is setLeft()/setTop().

    These result, if the click is in the lower part of the screen and the menu is long in white space below the application, just to show the menu.

    Click image for larger version

Name:	ListGrid Contextmenu.png
Views:	106
Size:	29.6 KB
ID:	255056

    The empty space is just there on right click and shifts the application up. It returns to normal when the menu is hidden.
    Is this expected? Am I somehow responsible to compute the position myself or is there a way to have this automatic fit by auto positioning it?

    Thank you & Best regards
    Blama

    #2
    The utility method menu.showContextMenu() will place a menu as close to the point as possible, but keep it onscreen. It also handles nuances like wanting to place to the left of the cursor for RTL locales.

    It does not currently introduce scrolling for a menu that is larger than the entire screen; you would have to do that part yourself.

    Comment


      #3
      Hi Isomorphic,

      thanks. I'll try that.
      Can you include this either in the top menu docs or create a ListGrid sample for it?
      My instinct was to call setTop()/setLeft() and draw().

      Best regards
      Blama

      Comment

      Working...
      X