nikhilbchilwant / google-web-toolkit-incubator

Automatically exported from code.google.com/p/google-web-toolkit-incubator
1 stars 1 forks source link

ContextMenu for PagingScrollTable/ScrollTable #263

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What version of gwt and gwt-incubator are you using?

GWT-1.6.4
GWT-Incubator (trunk r1619)

What OS and browser are you using?

Linux
Firefox 3.0.8

----

I need a context menu for PagingScrollTable/ScrollTable, but subclassing
FixedWidthGrid and adding the required functionality is not enough.

It seems that using Event.ONMOUSEDOWN in SelectionsGrid for the selection
functionality makes my extension useless, since Event.ONMOUSEDOWN is fired
before Event.ONCONTEXTMENU. Below is my FixedWidthGrid extension. The
attached files is a patch for FixedWidthGrid that handles all selections in
Event.ONCLICK (I use this patch as a workaround).

I don't know if there is another way to add a context menu to
PagingScrollTable/ScrollTable.

Thanks,
George.

---

  private class DataTable extends FixedWidthGrid {

    public DataTable() {
      super();

      sinkEvents(Event.ONCONTEXTMENU | Event.ONDBLCLICK);
    }

    public HandlerRegistration addDoubleClickHandler(DoubleClickHandler
handler) {
      return addHandler(handler, DoubleClickEvent.getType());
    }

    @Override
    public void onBrowserEvent(final Event event) {
      switch (event.getTypeInt()) {
        case Event.ONCONTEXTMENU:
          Element targetRow = null;
          Element targetCell = null;

          // Get the target row
          targetCell = getEventTargetCell(event);
          if (targetCell == null) {
            return;
          }
          targetRow = DOM.getParent(targetCell);
          int targetRowIndex = getRowIndex(targetRow);
          if (!isRowSelected(targetRowIndex)) {
            onMouseClick(event);
          }

          DOM.eventPreventDefault(event);
          // showContextMenu(event);
          break;
        case Event.ONDBLCLICK:
          DomEvent.fireNativeEvent(event, this, this.getElement());
        default:
          super.onBrowserEvent(event);
      }
    }
  }

Original issue reported on code.google.com by georgopo...@gmail.com on 11 Apr 2009 at 3:35

Attachments: