Example #1
0
 long /*int*/ menuItemSelected(long /*int*/ widget, ToolItem item) {
   Event event = new Event();
   switch (item.style) {
     case SWT.DROP_DOWN:
       /*
        * Feature in GTK. The DROP_DOWN item does not
        * contain arrow button in the overflow menu. So, it
        * is impossible to select the menu of that item.
        * The fix is to consider the item selection
        * as Arrow click, in order to popup the drop-down.
        */
       event.detail = SWT.ARROW;
       GtkAllocation allocation = new GtkAllocation();
       OS.gtk_widget_get_allocation(widget, allocation);
       event.x = allocation.x;
       if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - allocation.width - event.x;
       event.y = allocation.y + allocation.height;
       break;
     case SWT.RADIO:
       if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio();
       break;
     case SWT.CHECK:
       boolean currentSelection = item.getSelection();
       item.setSelection(!currentSelection);
   }
   item.sendSelectionEvent(SWT.Selection, event, false);
   return 0;
 }