Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 290303 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Control_Test.java (+1 lines)
Lines 786-789 Link Here
786
    assertNotNull( monitor );
786
    assertNotNull( monitor );
787
    assertEquals( display.getPrimaryMonitor(), monitor );
787
    assertEquals( display.getPrimaryMonitor(), monitor );
788
  }
788
  }
789
  
789
}
790
}
(-)src/org/eclipse/swt/internal/widgets/UntypedEventAdapter_Test.java (+3 lines)
Lines 110-115 Link Here
110
    adapter.addListener( SWT.Help, listener );
110
    adapter.addListener( SWT.Help, listener );
111
    adapter.helpRequested( new HelpEvent( widget ) );
111
    adapter.helpRequested( new HelpEvent( widget ) );
112
    assertEquals( SWT.Help, eventType );
112
    assertEquals( SWT.Help, eventType );
113
    adapter.addListener( SWT.MenuDetect, listener );
114
    adapter.menuDetected( new MenuDetectEvent( widget ) );
115
    assertEquals( SWT.MenuDetect, eventType );
113
  }
116
  }
114
117
115
  public void testAdditionAndRemovalOfListener() throws Exception {
118
  public void testAdditionAndRemovalOfListener() throws Exception {
(-)src/org/eclipse/swt/internal/widgets/UntypedEventAdapter.java (-1 / +24 lines)
Lines 35-41 Link Here
35
             TraverseListener,
35
             TraverseListener,
36
             ShowListener,
36
             ShowListener,
37
             ActivateListener,
37
             ActivateListener,
38
             HelpListener
38
             HelpListener,
39
             MenuDetectListener
39
{
40
{
40
41
41
  private class Entry {
42
  private class Entry {
Lines 225-230 Link Here
225
    dispatchEvent( event );
226
    dispatchEvent( event );
226
  }
227
  }
227
228
229
  public void menuDetected( final MenuDetectEvent typedEvent ) {
230
    Event event = createEvent( SWT.MenuDetect, typedEvent.getSource() );
231
    copyFields( typedEvent, event );
232
    dispatchEvent( event );
233
  }
234
228
  //////////////////////
235
  //////////////////////
229
  // Listener management
236
  // Listener management
230
237
Lines 278-283 Link Here
278
          MenuEvent.addListener( widget, this );
285
          MenuEvent.addListener( widget, this );
279
        }
286
        }
280
      break;
287
      break;
288
      case SWT.MenuDetect:
289
        MenuDetectEvent.addListener( widget, this );
290
      break;
281
      case SWT.Modify:
291
      case SWT.Modify:
282
        ModifyEvent.addListener( widget, this );
292
        ModifyEvent.addListener( widget, this );
283
      break;
293
      break;
Lines 361-366 Link Here
361
          MenuEvent.removeListener( widget, this );
371
          MenuEvent.removeListener( widget, this );
362
        }
372
        }
363
      break;
373
      break;
374
      case SWT.MenuDetect:
375
        MenuDetectEvent.removeListener( widget, this );
376
      break;
364
      case SWT.Modify:
377
      case SWT.Modify:
365
        ModifyEvent.removeListener( widget, this );
378
        ModifyEvent.removeListener( widget, this );
366
      break;
379
      break;
Lines 455-460 Link Here
455
          typedEvent = new MenuEvent( event );
468
          typedEvent = new MenuEvent( event );
456
        }
469
        }
457
      break;
470
      break;
471
      case SWT.MenuDetect:
472
        typedEvent = new MenuDetectEvent( event );
473
      break;
458
      case SWT.Modify:
474
      case SWT.Modify:
459
        typedEvent = new ModifyEvent( event );
475
        typedEvent = new ModifyEvent( event );
460
      break;
476
      break;
Lines 588-591 Link Here
588
    to.detail = from.detail;
604
    to.detail = from.detail;
589
    to.doit = from.doit;
605
    to.doit = from.doit;
590
  }
606
  }
607
608
  private static void copyFields( final MenuDetectEvent from, final Event to ) {
609
    copyFields( ( TypedEvent )from, to );
610
    to.x = from.x;
611
    to.y = from.y;
612
    to.doit = from.doit;
613
  }
591
}
614
}
(-)src/org/eclipse/swt/widgets/Control.java (+52 lines)
Lines 1719-1724 Link Here
1719
    HelpEvent.removeListener( this, listener );
1719
    HelpEvent.removeListener( this, listener );
1720
  }
1720
  }
1721
1721
1722
  /**
1723
   * Adds the listener to the collection of listeners who will
1724
   * be notified when the platform-specific context menu trigger
1725
   * has occurred, by sending it one of the messages defined in
1726
   * the <code>MenuDetectListener</code> interface.
1727
   *
1728
   * @param listener the listener which should be notified
1729
   *
1730
   * @exception IllegalArgumentException <ul>
1731
   *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
1732
   * </ul>
1733
   * @exception SWTException <ul>
1734
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1735
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
1736
   *                                      created the receiver</li>
1737
   * </ul>
1738
   *
1739
   * @see MenuDetectListener
1740
   * @see #removeMenuDetectListener
1741
   *
1742
   * @since 1.3
1743
   */
1744
  public void addMenuDetectListener( final MenuDetectListener listener ) {
1745
    checkWidget ();
1746
    MenuDetectEvent.addListener( this, listener );
1747
  }
1748
1749
  /**
1750
   * Removes the listener from the collection of listeners who will
1751
   * be notified when the platform-specific context menu trigger has
1752
   * occurred.
1753
   *
1754
   * @param listener the listener which should no longer be notified
1755
   *
1756
   * @exception IllegalArgumentException <ul>
1757
   *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
1758
   * </ul>
1759
   * @exception SWTException <ul>
1760
   *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1761
   *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1762
   * </ul>
1763
   *
1764
   * @see MenuDetectListener
1765
   * @see #addMenuDetectListener
1766
   *
1767
   * @since 1.3
1768
   */
1769
  public void removeMenuDetectListener( final MenuDetectListener listener ) {
1770
    checkWidget ();
1771
    MenuDetectEvent.removeListener( this, listener );
1772
  }
1773
  
1722
  ////////////////
1774
  ////////////////
1723
  // drawing (Note that we can't really force a redraw. This is just a
1775
  // drawing (Note that we can't really force a redraw. This is just a
1724
  // fake to for event notifications that come on OS systems
1776
  // fake to for event notifications that come on OS systems
(-)src/org/eclipse/swt/events/TypedEvent.java (+1 lines)
Lines 52-57 Link Here
52
    DisposeEvent.class,
52
    DisposeEvent.class,
53
    SetDataEvent.class,
53
    SetDataEvent.class,
54
    FocusEvent.class,
54
    FocusEvent.class,
55
    MenuDetectEvent.class,
55
    MouseEvent.class,
56
    MouseEvent.class,
56
    VerifyEvent.class,
57
    VerifyEvent.class,
57
    ModifyEvent.class,
58
    ModifyEvent.class,
(-)src/org/eclipse/swt/SWT.java (+11 lines)
Lines 365-370 Link Here
365
  public static final int Traverse = 31;
365
  public static final int Traverse = 31;
366
366
367
  /**
367
  /**
368
   * The menu detect event type (value is 35).
369
   * 
370
   * @see org.eclipse.swt.widgets.Widget#addListener
371
   * @see org.eclipse.swt.widgets.Display#addFilter
372
   * @see org.eclipse.swt.widgets.Event
373
   * 
374
   * @since 1.3
375
   */
376
  public static final int MenuDetect = 35;
377
  
378
  /**
368
   * The set data event type (value is 36).
379
   * The set data event type (value is 36).
369
   *
380
   *
370
   * @see org.eclipse.swt.widgets.Widget#addListener
381
   * @see org.eclipse.swt.widgets.Widget#addListener
(-)src/org/eclipse/swt/events/MenuDetectListener.java (+31 lines)
Added Link Here
1
package org.eclipse.swt.events;
2
3
import org.eclipse.swt.internal.SWTEventListener;
4
5
/**
6
 * Classes which implement this interface provide methods
7
 * that deal with the events that are generated when the
8
 * platform-specific trigger for showing a context menu is
9
 * detected.
10
 * <p>
11
 * After creating an instance of a class that implements
12
 * this interface it can be added to a control <!-- or TrayItem -->
13
 * using the <code>addMenuDetectListener</code> method and
14
 * removed using the <code>removeMenuDetectListener</code> method.
15
 * When the context menu trigger occurs, the
16
 * <code>menuDetected</code> method will be invoked.
17
 * </p>
18
 *
19
 * @see MenuDetectEvent
20
 *
21
 * @since 1.3
22
 */
23
public interface MenuDetectListener extends SWTEventListener {
24
25
/**
26
 * Sent when the platform-dependent trigger for showing a menu item is detected.
27
 *
28
 * @param e an event containing information about the menu detect
29
 */
30
public void menuDetected(MenuDetectEvent e);
31
}
(-)src/org/eclipse/swt/events/MenuDetectEvent.java (+133 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.swt.events;
12
13
14
import org.eclipse.rwt.Adaptable;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.internal.widgets.EventUtil;
17
import org.eclipse.swt.widgets.Event;
18
import org.eclipse.swt.widgets.Widget;
19
20
/**
21
 * Instances of this class are sent whenever the platform-
22
 * specific trigger for showing a context menu is detected.
23
 *
24
 * @see MenuDetectListener
25
 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
26
 *
27
 * @since 1.3
28
 */
29
30
public final class MenuDetectEvent extends TypedEvent {
31
32
	/**
33
	 * the display-relative x coordinate of the pointer
34
	 * at the time the context menu trigger occurred
35
	 */
36
	public int x;
37
	
38
	/**
39
	 * the display-relative y coordinate of the pointer
40
	 * at the time the context menu trigger occurred
41
	 */	
42
	public int y;
43
	
44
	/**
45
	 * A flag indicating whether the operation should be allowed.
46
	 * Setting this field to <code>false</code> will cancel the operation.
47
	 */
48
	public boolean doit;
49
50
	private static final long serialVersionUID = -3061660596590828941L;
51
52
  private static final int MENU_DETECT = SWT.MenuDetect;
53
  
54
  private static final Class LISTENER = MenuDetectListener.class;
55
56
/**
57
 * Constructs a new instance of this class based on the
58
 * information in the given untyped event.
59
 *
60
 * @param e the untyped event containing the information
61
 */
62
  public MenuDetectEvent( final Event event ) {
63
    super( event.widget, event.type );
64
    this.x = event.x;
65
    this.y = event.y;
66
    this.doit = event.doit;
67
  }
68
69
/**
70
 * Returns a string containing a concise, human-readable
71
 * description of the receiver.
72
 *
73
 * @return a string representation of the event
74
 */
75
public String toString() {
76
	String string = super.toString ();
77
	return string.substring (0, string.length() - 1) // remove trailing '}'
78
		+ " x=" + x
79
		+ " y=" + y
80
		+ " doit=" + doit
81
		+ "}";
82
}
83
84
/**
85
 * Constructs a new instance of this class. 
86
 * <p><strong>IMPORTANT:</strong> This method is <em>not</em> part of the RWT
87
 * public API. It is marked public only so that it can be shared
88
 * within the packages provided by RWT. It should never be accessed 
89
 * from application code.
90
 * </p>
91
 */
92
  public MenuDetectEvent( final Widget source ) {
93
    super( source, MENU_DETECT );
94
  }
95
96
  protected void dispatchToObserver( final Object listener ) {
97
    switch( getID() ) {
98
      case MENU_DETECT:
99
        ( ( MenuDetectListener )listener ).menuDetected( this );
100
      break;
101
      default:
102
        throw new IllegalStateException( "Invalid event handler type." );
103
    }
104
  }
105
106
  protected Class getListenerType() {
107
    return LISTENER;
108
  }
109
110
  protected boolean allowProcessing() {
111
    return EventUtil.isAccessible( widget );
112
  }
113
114
  public static void addListener( final Adaptable adaptable,
115
                                  final MenuDetectListener listener )
116
  {
117
    addListener( adaptable, LISTENER, listener );
118
  }
119
120
  public static void removeListener( final Adaptable adaptable,
121
                                     final MenuDetectListener listener )
122
  {
123
    removeListener( adaptable, LISTENER, listener );
124
  }
125
126
  public static boolean hasListener( final Adaptable adaptable ) {
127
    return hasListener( adaptable, LISTENER );
128
  }
129
130
  public static Object[] getListeners( final Adaptable adaptable ) {
131
    return getListener( adaptable, LISTENER );
132
  }
133
}
(-)src/org/eclipse/swt/internal/widgets/controlkit/ControlLCA_Test.java (-2 / +26 lines)
Lines 18-30 Link Here
18
import org.eclipse.rwt.graphics.Graphics;
18
import org.eclipse.rwt.graphics.Graphics;
19
import org.eclipse.rwt.internal.browser.Mozilla1_7up;
19
import org.eclipse.rwt.internal.browser.Mozilla1_7up;
20
import org.eclipse.rwt.internal.lifecycle.DisplayUtil;
20
import org.eclipse.rwt.internal.lifecycle.DisplayUtil;
21
import org.eclipse.rwt.internal.lifecycle.JSConst;
21
import org.eclipse.rwt.internal.service.RequestParams;
22
import org.eclipse.rwt.internal.service.RequestParams;
22
import org.eclipse.rwt.internal.theme.ThemeManager;
23
import org.eclipse.rwt.internal.theme.ThemeManager;
23
import org.eclipse.rwt.lifecycle.*;
24
import org.eclipse.rwt.lifecycle.*;
24
import org.eclipse.swt.RWTFixture;
25
import org.eclipse.swt.RWTFixture;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.ControlAdapter;
27
import org.eclipse.swt.events.*;
27
import org.eclipse.swt.events.FocusAdapter;
28
import org.eclipse.swt.graphics.*;
28
import org.eclipse.swt.graphics.*;
29
import org.eclipse.swt.internal.events.ActivateAdapter;
29
import org.eclipse.swt.internal.events.ActivateAdapter;
30
import org.eclipse.swt.internal.events.ActivateEvent;
30
import org.eclipse.swt.internal.events.ActivateEvent;
Lines 227-232 Link Here
227
    assertEquals( -1, markup.indexOf( focusLost ) );
227
    assertEquals( -1, markup.indexOf( focusLost ) );
228
  }
228
  }
229
229
230
  public void testMenuDetectListener() {
231
    RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
232
    Display display = new Display();
233
    Shell shell = new Shell( display );
234
    Label label = new Label( shell, SWT.NONE );
235
    final StringBuffer log = new StringBuffer();
236
    label.addMenuDetectListener( new MenuDetectListener() {
237
      public void menuDetected( MenuDetectEvent e ) {
238
        log.append( e.x );
239
        log.append( "|" );
240
        log.append( e.y );
241
      }
242
    });
243
    String displayId = DisplayUtil.getId( display );
244
    String labelId = WidgetUtil.getId( label );
245
    Fixture.fakeResponseWriter();
246
    Fixture.fakeRequestParam( RequestParams.UIROOT, displayId );
247
    Fixture.fakeRequestParam( JSConst.EVENT_MENU_DETECT, labelId );
248
    Fixture.fakeRequestParam( JSConst.EVENT_MENU_DETECT_X, "10" );
249
    Fixture.fakeRequestParam( JSConst.EVENT_MENU_DETECT_Y, "30" );
250
    RWTFixture.executeLifeCycleFromServerThread();
251
    assertEquals( "10|30", log.toString() );
252
  }
253
  
230
  public void testRedrawAndDispose() {
254
  public void testRedrawAndDispose() {
231
    final StringBuffer log = new StringBuffer();
255
    final StringBuffer log = new StringBuffer();
232
    // Set up test scenario
256
    // Set up test scenario
(-)src/org/eclipse/swt/internal/custom/clabelkit/CLabelLCA.java (+1 lines)
Lines 44-49 Link Here
44
    CLabel label = ( CLabel )widget;
44
    CLabel label = ( CLabel )widget;
45
    ControlLCAUtil.processMouseEvents( label );
45
    ControlLCAUtil.processMouseEvents( label );
46
    ControlLCAUtil.processKeyEvents( label );
46
    ControlLCAUtil.processKeyEvents( label );
47
    ControlLCAUtil.processMenuDetect( label );
47
    WidgetLCAUtil.processHelp( label );
48
    WidgetLCAUtil.processHelp( label );
48
  }
49
  }
49
50
(-)src/org/eclipse/swt/internal/custom/scrolledcompositekit/ScrolledCompositeLCA.java (+1 lines)
Lines 80-85 Link Here
80
    composite.setOrigin( origin );
80
    composite.setOrigin( origin );
81
    ControlLCAUtil.processMouseEvents( composite );
81
    ControlLCAUtil.processMouseEvents( composite );
82
    ControlLCAUtil.processKeyEvents( composite );
82
    ControlLCAUtil.processKeyEvents( composite );
83
    ControlLCAUtil.processMenuDetect( composite );
83
    WidgetLCAUtil.processHelp( composite );
84
    WidgetLCAUtil.processHelp( composite );
84
  }
85
  }
85
86
(-)src/org/eclipse/swt/internal/widgets/combokit/ComboLCA.java (+1 lines)
Lines 95-100 Link Here
95
    ControlLCAUtil.processSelection( combo, null, true );
95
    ControlLCAUtil.processSelection( combo, null, true );
96
    ControlLCAUtil.processMouseEvents( combo );
96
    ControlLCAUtil.processMouseEvents( combo );
97
    ControlLCAUtil.processKeyEvents( combo );
97
    ControlLCAUtil.processKeyEvents( combo );
98
    ControlLCAUtil.processMenuDetect( combo );
98
    WidgetLCAUtil.processHelp( combo );
99
    WidgetLCAUtil.processHelp( combo );
99
  }
100
  }
100
101
(-)src/org/eclipse/swt/internal/widgets/expandbarkit/ExpandBarLCA.java (+1 lines)
Lines 37-42 Link Here
37
37
38
  public void readData( final Widget widget ) {
38
  public void readData( final Widget widget ) {
39
    ControlLCAUtil.processKeyEvents( ( Control )widget );
39
    ControlLCAUtil.processKeyEvents( ( Control )widget );
40
    ControlLCAUtil.processMenuDetect( ( Control )widget );
40
    WidgetLCAUtil.processHelp( widget );
41
    WidgetLCAUtil.processHelp( widget );
41
  }
42
  }
42
43
(-)src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeTimeLCA.java (+1 lines)
Lines 60-65 Link Here
60
    ControlLCAUtil.processSelection( dateTime, null, true );
60
    ControlLCAUtil.processSelection( dateTime, null, true );
61
    ControlLCAUtil.processMouseEvents( dateTime );
61
    ControlLCAUtil.processMouseEvents( dateTime );
62
    ControlLCAUtil.processKeyEvents( dateTime );
62
    ControlLCAUtil.processKeyEvents( dateTime );
63
    ControlLCAUtil.processMenuDetect( dateTime );
63
    WidgetLCAUtil.processHelp( dateTime );
64
    WidgetLCAUtil.processHelp( dateTime );
64
  }
65
  }
65
66
(-)src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeCalendarLCA.java (+1 lines)
Lines 55-60 Link Here
55
    ControlLCAUtil.processSelection( dateTime, null, true );
55
    ControlLCAUtil.processSelection( dateTime, null, true );
56
    ControlLCAUtil.processMouseEvents( dateTime );
56
    ControlLCAUtil.processMouseEvents( dateTime );
57
    ControlLCAUtil.processKeyEvents( dateTime );
57
    ControlLCAUtil.processKeyEvents( dateTime );
58
    ControlLCAUtil.processMenuDetect( dateTime );
58
    WidgetLCAUtil.processHelp( dateTime );
59
    WidgetLCAUtil.processHelp( dateTime );
59
  }
60
  }
60
61
(-)src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeDateLCA.java (+1 lines)
Lines 60-65 Link Here
60
    ControlLCAUtil.processSelection( dateTime, null, true );
60
    ControlLCAUtil.processSelection( dateTime, null, true );
61
    ControlLCAUtil.processMouseEvents( dateTime );
61
    ControlLCAUtil.processMouseEvents( dateTime );
62
    ControlLCAUtil.processKeyEvents( dateTime );
62
    ControlLCAUtil.processKeyEvents( dateTime );
63
    ControlLCAUtil.processMenuDetect( dateTime );
63
    WidgetLCAUtil.processHelp( dateTime );
64
    WidgetLCAUtil.processHelp( dateTime );
64
  }
65
  }
65
66
(-)src/org/eclipse/swt/internal/widgets/textkit/SingleTextLCA.java (+1 lines)
Lines 35-40 Link Here
35
    ControlLCAUtil.processSelection( text, null, false );
35
    ControlLCAUtil.processSelection( text, null, false );
36
    ControlLCAUtil.processMouseEvents( text );
36
    ControlLCAUtil.processMouseEvents( text );
37
    ControlLCAUtil.processKeyEvents( text );
37
    ControlLCAUtil.processKeyEvents( text );
38
    ControlLCAUtil.processMenuDetect( text );
38
    WidgetLCAUtil.processHelp( text );
39
    WidgetLCAUtil.processHelp( text );
39
  }
40
  }
40
41
(-)src/org/eclipse/swt/internal/widgets/textkit/MultiTextLCA.java (+1 lines)
Lines 34-39 Link Here
34
    TextLCAUtil.readTextAndSelection( text );
34
    TextLCAUtil.readTextAndSelection( text );
35
    ControlLCAUtil.processMouseEvents( text );
35
    ControlLCAUtil.processMouseEvents( text );
36
    ControlLCAUtil.processKeyEvents( text );
36
    ControlLCAUtil.processKeyEvents( text );
37
    ControlLCAUtil.processMenuDetect( text );
37
    WidgetLCAUtil.processHelp( text );
38
    WidgetLCAUtil.processHelp( text );
38
  }
39
  }
39
40
(-)src/org/eclipse/swt/internal/widgets/textkit/PasswordTextLCA.java (+1 lines)
Lines 34-39 Link Here
34
    ControlLCAUtil.processSelection( text, null, false );
34
    ControlLCAUtil.processSelection( text, null, false );
35
    ControlLCAUtil.processMouseEvents( text );
35
    ControlLCAUtil.processMouseEvents( text );
36
    ControlLCAUtil.processKeyEvents( text );
36
    ControlLCAUtil.processKeyEvents( text );
37
    ControlLCAUtil.processMenuDetect( text );
37
    WidgetLCAUtil.processHelp( text );
38
    WidgetLCAUtil.processHelp( text );
38
  }
39
  }
39
40
(-)src/org/eclipse/swt/internal/widgets/buttonkit/PushButtonDelegateLCA.java (+1 lines)
Lines 34-39 Link Here
34
    ButtonLCAUtil.readSelection( button );
34
    ButtonLCAUtil.readSelection( button );
35
    ControlLCAUtil.processMouseEvents( button );
35
    ControlLCAUtil.processMouseEvents( button );
36
    ControlLCAUtil.processKeyEvents( button );
36
    ControlLCAUtil.processKeyEvents( button );
37
    ControlLCAUtil.processMenuDetect( button );
37
    WidgetLCAUtil.processHelp( button );
38
    WidgetLCAUtil.processHelp( button );
38
  }
39
  }
39
40
(-)src/org/eclipse/swt/internal/widgets/buttonkit/CheckButtonDelegateLCA.java (+1 lines)
Lines 36-41 Link Here
36
    ControlLCAUtil.processSelection( button, null, true );
36
    ControlLCAUtil.processSelection( button, null, true );
37
    ControlLCAUtil.processMouseEvents( button );
37
    ControlLCAUtil.processMouseEvents( button );
38
    ControlLCAUtil.processKeyEvents( button );
38
    ControlLCAUtil.processKeyEvents( button );
39
    ControlLCAUtil.processMenuDetect( button );
39
    WidgetLCAUtil.processHelp( button );
40
    WidgetLCAUtil.processHelp( button );
40
  }
41
  }
41
42
(-)src/org/eclipse/swt/internal/widgets/buttonkit/RadioButtonDelegateLCA.java (+1 lines)
Lines 39-44 Link Here
39
    }
39
    }
40
    ControlLCAUtil.processMouseEvents( button );
40
    ControlLCAUtil.processMouseEvents( button );
41
    ControlLCAUtil.processKeyEvents( button );
41
    ControlLCAUtil.processKeyEvents( button );
42
    ControlLCAUtil.processMenuDetect( button );
42
    WidgetLCAUtil.processHelp( button );
43
    WidgetLCAUtil.processHelp( button );
43
  }
44
  }
44
45
(-)src/org/eclipse/swt/internal/widgets/coolbarkit/CoolBarLCA.java (+1 lines)
Lines 32-37 Link Here
32
    Control coolBar = ( Control )widget;
32
    Control coolBar = ( Control )widget;
33
    ControlLCAUtil.processMouseEvents( coolBar );
33
    ControlLCAUtil.processMouseEvents( coolBar );
34
    ControlLCAUtil.processKeyEvents( coolBar );
34
    ControlLCAUtil.processKeyEvents( coolBar );
35
    ControlLCAUtil.processMenuDetect( coolBar );
35
    WidgetLCAUtil.processHelp( coolBar );
36
    WidgetLCAUtil.processHelp( coolBar );
36
  }
37
  }
37
38
(-)src/org/eclipse/swt/internal/widgets/labelkit/StandardLabelLCA.java (+1 lines)
Lines 51-56 Link Here
51
  void readData( final Label label ) {
51
  void readData( final Label label ) {
52
    ControlLCAUtil.processMouseEvents( label );
52
    ControlLCAUtil.processMouseEvents( label );
53
    ControlLCAUtil.processKeyEvents( label );
53
    ControlLCAUtil.processKeyEvents( label );
54
    ControlLCAUtil.processMenuDetect( label );
54
    WidgetLCAUtil.processHelp( label );
55
    WidgetLCAUtil.processHelp( label );
55
  }
56
  }
56
57
(-)src/org/eclipse/swt/internal/widgets/labelkit/SeparatorLabelLCA.java (+1 lines)
Lines 37-42 Link Here
37
  void readData( final Label label ) {
37
  void readData( final Label label ) {
38
    ControlLCAUtil.processMouseEvents( label );
38
    ControlLCAUtil.processMouseEvents( label );
39
    ControlLCAUtil.processKeyEvents( label );
39
    ControlLCAUtil.processKeyEvents( label );
40
    ControlLCAUtil.processMenuDetect( label );
40
    WidgetLCAUtil.processHelp( label );
41
    WidgetLCAUtil.processHelp( label );
41
  }
42
  }
42
43
(-)src/org/eclipse/swt/internal/widgets/progressbarkit/ProgressBarLCA.java (+1 lines)
Lines 42-47 Link Here
42
    ProgressBar progressBar = ( ProgressBar )widget;
42
    ProgressBar progressBar = ( ProgressBar )widget;
43
    ControlLCAUtil.processMouseEvents( progressBar );
43
    ControlLCAUtil.processMouseEvents( progressBar );
44
    ControlLCAUtil.processKeyEvents( progressBar );
44
    ControlLCAUtil.processKeyEvents( progressBar );
45
    ControlLCAUtil.processMenuDetect( progressBar );
45
    WidgetLCAUtil.processHelp( progressBar );
46
    WidgetLCAUtil.processHelp( progressBar );
46
  }
47
  }
47
48
(-)src/org/eclipse/swt/internal/widgets/toolbarkit/ToolBarLCA.java (+1 lines)
Lines 33-38 Link Here
33
  public void readData( final  Widget widget ) {
33
  public void readData( final  Widget widget ) {
34
    ControlLCAUtil.processMouseEvents( ( Control )widget );
34
    ControlLCAUtil.processMouseEvents( ( Control )widget );
35
    ControlLCAUtil.processKeyEvents( ( Control )widget );
35
    ControlLCAUtil.processKeyEvents( ( Control )widget );
36
    ControlLCAUtil.processMenuDetect( ( Control )widget );
36
    WidgetLCAUtil.processHelp( widget );
37
    WidgetLCAUtil.processHelp( widget );
37
  }
38
  }
38
39
(-)src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java (+1 lines)
Lines 105-110 Link Here
105
    readCellToolTipTextRequested( table );
105
    readCellToolTipTextRequested( table );
106
    ControlLCAUtil.processMouseEvents( table );
106
    ControlLCAUtil.processMouseEvents( table );
107
    ControlLCAUtil.processKeyEvents( table );
107
    ControlLCAUtil.processKeyEvents( table );
108
    ControlLCAUtil.processMenuDetect( table );
108
  }
109
  }
109
110
110
  public void renderInitialization( final Widget widget ) throws IOException {
111
  public void renderInitialization( final Widget widget ) throws IOException {
(-)src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java (+1 lines)
Lines 61-66 Link Here
61
    processWidgetDefaultSelectedEvent( tree );
61
    processWidgetDefaultSelectedEvent( tree );
62
    ControlLCAUtil.processMouseEvents( tree );
62
    ControlLCAUtil.processMouseEvents( tree );
63
    ControlLCAUtil.processKeyEvents( tree );
63
    ControlLCAUtil.processKeyEvents( tree );
64
    ControlLCAUtil.processMenuDetect( tree );
64
    WidgetLCAUtil.processHelp( tree );
65
    WidgetLCAUtil.processHelp( tree );
65
  }
66
  }
66
67
(-)src/org/eclipse/swt/internal/widgets/sashkit/SashLCA.java (+1 lines)
Lines 39-44 Link Here
39
    Sash sash = ( Sash )widget;
39
    Sash sash = ( Sash )widget;
40
    ControlLCAUtil.processMouseEvents( sash );
40
    ControlLCAUtil.processMouseEvents( sash );
41
    ControlLCAUtil.processKeyEvents( sash );
41
    ControlLCAUtil.processKeyEvents( sash );
42
    ControlLCAUtil.processMenuDetect( sash );
42
    WidgetLCAUtil.processHelp( sash );
43
    WidgetLCAUtil.processHelp( sash );
43
  }
44
  }
44
45
(-)src/org/eclipse/swt/internal/widgets/groupkit/GroupLCA.java (+1 lines)
Lines 32-37 Link Here
32
  public void readData( final Widget widget ) {
32
  public void readData( final Widget widget ) {
33
    ControlLCAUtil.processMouseEvents( ( Group )widget );
33
    ControlLCAUtil.processMouseEvents( ( Group )widget );
34
    ControlLCAUtil.processKeyEvents( ( Group )widget );
34
    ControlLCAUtil.processKeyEvents( ( Group )widget );
35
    ControlLCAUtil.processMenuDetect( ( Group )widget );
35
    WidgetLCAUtil.processHelp( widget );
36
    WidgetLCAUtil.processHelp( widget );
36
  }
37
  }
37
38
(-)src/org/eclipse/swt/internal/custom/ccombokit/CComboLCA.java (+1 lines)
Lines 86-91 Link Here
86
    ControlLCAUtil.processSelection( ccombo, null, true );
86
    ControlLCAUtil.processSelection( ccombo, null, true );
87
    ControlLCAUtil.processMouseEvents( ccombo );
87
    ControlLCAUtil.processMouseEvents( ccombo );
88
    ControlLCAUtil.processKeyEvents( ccombo );
88
    ControlLCAUtil.processKeyEvents( ccombo );
89
    ControlLCAUtil.processMenuDetect( ccombo );
89
    WidgetLCAUtil.processHelp( ccombo );
90
    WidgetLCAUtil.processHelp( ccombo );
90
  }
91
  }
91
92
(-)src/org/eclipse/swt/internal/custom/ctabfolderkit/CTabFolderLCA.java (+2 lines)
Lines 179-184 Link Here
179
    ControlLCAUtil.processMouseEvents( tabFolder );
179
    ControlLCAUtil.processMouseEvents( tabFolder );
180
    // Key events
180
    // Key events
181
    ControlLCAUtil.processKeyEvents( tabFolder );
181
    ControlLCAUtil.processKeyEvents( tabFolder );
182
    // Menu Detect events
183
    ControlLCAUtil.processMenuDetect( tabFolder );
182
    // Help events
184
    // Help events
183
    WidgetLCAUtil.processHelp( tabFolder );
185
    WidgetLCAUtil.processHelp( tabFolder );
184
  }
186
  }
(-)src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java (+1 lines)
Lines 73-78 Link Here
73
    processActivate( shell );
73
    processActivate( shell );
74
    ControlLCAUtil.processMouseEvents( shell );
74
    ControlLCAUtil.processMouseEvents( shell );
75
    ControlLCAUtil.processKeyEvents( shell );
75
    ControlLCAUtil.processKeyEvents( shell );
76
    ControlLCAUtil.processMenuDetect( shell );
76
    WidgetLCAUtil.processHelp( shell );
77
    WidgetLCAUtil.processHelp( shell );
77
  }
78
  }
78
79
(-)src/org/eclipse/swt/internal/widgets/compositekit/CompositeLCA.java (+1 lines)
Lines 32-37 Link Here
32
  public void readData( final Widget widget ) {
32
  public void readData( final Widget widget ) {
33
    ControlLCAUtil.processMouseEvents( ( Control )widget );
33
    ControlLCAUtil.processMouseEvents( ( Control )widget );
34
    ControlLCAUtil.processKeyEvents( ( Control )widget );
34
    ControlLCAUtil.processKeyEvents( ( Control )widget );
35
    ControlLCAUtil.processMenuDetect( ( Control )widget );
35
  }
36
  }
36
37
37
  public void renderInitialization( final Widget widget ) throws IOException {
38
  public void renderInitialization( final Widget widget ) throws IOException {
(-)src/org/eclipse/swt/internal/widgets/listkit/ListLCA.java (+1 lines)
Lines 62-67 Link Here
62
    ControlLCAUtil.processSelection( list, null, true );
62
    ControlLCAUtil.processSelection( list, null, true );
63
    ControlLCAUtil.processMouseEvents( list );
63
    ControlLCAUtil.processMouseEvents( list );
64
    ControlLCAUtil.processKeyEvents( list );
64
    ControlLCAUtil.processKeyEvents( list );
65
    ControlLCAUtil.processMenuDetect( list );
65
    WidgetLCAUtil.processHelp( list );
66
    WidgetLCAUtil.processHelp( list );
66
  }
67
  }
67
68
(-)src/org/eclipse/swt/internal/widgets/tabfolderkit/TabFolderLCA.java (+1 lines)
Lines 29-34 Link Here
29
  public void readData( final Widget widget ) {
29
  public void readData( final Widget widget ) {
30
    ControlLCAUtil.processMouseEvents( ( TabFolder )widget );
30
    ControlLCAUtil.processMouseEvents( ( TabFolder )widget );
31
    ControlLCAUtil.processKeyEvents( ( TabFolder )widget );
31
    ControlLCAUtil.processKeyEvents( ( TabFolder )widget );
32
    ControlLCAUtil.processMenuDetect( ( TabFolder )widget );
32
    WidgetLCAUtil.processHelp( widget );
33
    WidgetLCAUtil.processHelp( widget );
33
  }
34
  }
34
35
(-)js/org/eclipse/swt/EventUtil.js (+41 lines)
Lines 295-300 Link Here
295
          req.send();
295
          req.send();
296
        }
296
        }
297
      }
297
      }
298
    },
299
    
300
    menuDetectedByKey : function( evt ) {
301
    	if( evt.getKeyIdentifier() === "Apps" ) {
302
        // stop further handling and default handling by the browser
303
        evt.stopPropagation();
304
        evt.preventDefault();
305
        org.eclipse.swt.EventUtil.sendMenuDetected( evt.getTarget(), 0, 0 );
306
      }
307
    },
308
309
    menuDetectedByMouse : function( evt ) {
310
      if( evt.getButton() === qx.event.type.MouseEvent.C_BUTTON_RIGHT ) {
311
        // stop further handling and default handling by the browser
312
        evt.stopPropagation();
313
        evt.preventDefault();
314
        var x = evt.getPageX();
315
        var y = evt.getPageY();
316
        org.eclipse.swt.EventUtil.sendMenuDetected( evt.getTarget(), x, y );
317
      }
318
    },
319
320
    sendMenuDetected : function( widget, x, y ) {
321
    	if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
322
        // send menu detect request to server
323
        var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
324
        //var id = widgetManager.findIdByWidget( widget );
325
        // find parent control for the widget that received the event in case 
326
        // it wasn't the control itself that received the event
327
        while( widget != null && !widgetManager.isControl( widget ) ) {
328
          widget = widget.getParent ? widget.getParent() : null;
329
        }
330
        var id = widgetManager.findIdByWidget( widget );
331
        if( id != null ) {
332
          var req = org.eclipse.swt.Request.getInstance();
333
          req.addEvent( "org.eclipse.swt.events.menuDetect", id );
334
          req.addParameter( "org.eclipse.swt.events.menuDetect.x", x );
335
          req.addParameter( "org.eclipse.swt.events.menuDetect.y", y );
336
          req.send();
337
        }
338
    	}
298
    }
339
    }
299
340
300
  }
341
  }
(-)src/org/eclipse/swt/internal/widgets/spinnerkit/SpinnerLCA.java (+1 lines)
Lines 67-72 Link Here
67
    ControlLCAUtil.processSelection( widget, null, false );
67
    ControlLCAUtil.processSelection( widget, null, false );
68
    ControlLCAUtil.processMouseEvents( spinner );
68
    ControlLCAUtil.processMouseEvents( spinner );
69
    ControlLCAUtil.processKeyEvents( spinner );
69
    ControlLCAUtil.processKeyEvents( spinner );
70
    ControlLCAUtil.processMenuDetect( spinner );
70
    WidgetLCAUtil.processHelp( spinner );
71
    WidgetLCAUtil.processHelp( spinner );
71
  }
72
  }
72
73
(-)src/org/eclipse/rwt/internal/lifecycle/JSConst.java (+6 lines)
Lines 58-63 Link Here
58
    = "org.eclipse.swt.events.keyDown";
58
    = "org.eclipse.swt.events.keyDown";
59
  public static final String EVENT_HELP
59
  public static final String EVENT_HELP
60
    = "org.eclipse.swt.events.help";
60
    = "org.eclipse.swt.events.help";
61
  public static final String EVENT_MENU_DETECT
62
    = "org.eclipse.swt.events.menuDetect";
61
63
62
64
63
  // Parameter names that specify further event details
65
  // Parameter names that specify further event details
Lines 99-104 Link Here
99
    = "org.eclipse.swt.events.keyDown.charCode";
101
    = "org.eclipse.swt.events.keyDown.charCode";
100
  public static final String EVENT_KEY_DOWN_MODIFIER
102
  public static final String EVENT_KEY_DOWN_MODIFIER
101
    = "org.eclipse.swt.events.keyDown.modifier";
103
    = "org.eclipse.swt.events.keyDown.modifier";
104
  public static final String EVENT_MENU_DETECT_X
105
    = "org.eclipse.swt.events.menuDetect.x";
106
  public static final String EVENT_MENU_DETECT_Y
107
    = "org.eclipse.swt.events.menuDetect.y";
102
108
103
  // Indicates that a shell was closed on the client side. The parameter
109
  // Indicates that a shell was closed on the client side. The parameter
104
  // value holds the id of the shell that was closed.
110
  // value holds the id of the shell that was closed.
(-)src/org/eclipse/rwt/lifecycle/ControlLCAUtil.java (-1 / +71 lines)
Lines 58-64 Link Here
58
    = new JSListenerInfo( "mouseup",
58
    = new JSListenerInfo( "mouseup",
59
                          "org.eclipse.swt.EventUtil.mouseUp",
59
                          "org.eclipse.swt.EventUtil.mouseUp",
60
                          JSListenerType.ACTION );
60
                          JSListenerType.ACTION );
61
61
  private static final JSListenerInfo MENU_DETECT_LISTENER_INFO_MOUSE
62
    = new JSListenerInfo( "keydown",
63
                          "org.eclipse.swt.EventUtil.menuDetectedByKey",
64
                          JSListenerType.ACTION );
65
  private static final JSListenerInfo MENU_DETECT_LISTENER_INFO_KEY
66
  = new JSListenerInfo( "mouseup",
67
                        "org.eclipse.swt.EventUtil.menuDetectedByMouse",
68
                        JSListenerType.ACTION );
69
  
62
  private static final String JS_FUNC_ADD_ACTIVATE_LISTENER_WIDGET
70
  private static final String JS_FUNC_ADD_ACTIVATE_LISTENER_WIDGET
63
    = "addActivateListenerWidget";
71
    = "addActivateListenerWidget";
64
  private static final String JS_FUNC_REMOVE_ACTIVATE_LISTENER_WIDGET
72
  private static final String JS_FUNC_REMOVE_ACTIVATE_LISTENER_WIDGET
Lines 70-75 Link Here
70
  private static final String PROP_MOUSE_LISTENER = "mouseListener";
78
  private static final String PROP_MOUSE_LISTENER = "mouseListener";
71
  private static final String PROP_KEY_LISTENER = "keyListener";
79
  private static final String PROP_KEY_LISTENER = "keyListener";
72
  private static final String PROP_TRAVERSE_LISTENER = "traverseListener";
80
  private static final String PROP_TRAVERSE_LISTENER = "traverseListener";
81
  private static final String PROP_MENU_DETECT_LISTENER = "menuDetectListener";
73
  private static final String PROP_TAB_INDEX = "tabIndex";
82
  private static final String PROP_TAB_INDEX = "tabIndex";
74
  private static final String PROP_CURSOR = "cursor";
83
  private static final String PROP_CURSOR = "cursor";
75
  private static final String PROP_BACKGROUND_IMAGE = "backgroundImage";
84
  private static final String PROP_BACKGROUND_IMAGE = "backgroundImage";
Lines 113-118 Link Here
113
   * <li>whether KeyListeners are registered</li>
122
   * <li>whether KeyListeners are registered</li>
114
   * <li>whether TraverseListeners are registered</li>
123
   * <li>whether TraverseListeners are registered</li>
115
   * <li>whether HelpListeners are registered</li>
124
   * <li>whether HelpListeners are registered</li>
125
   * <li>whether MenuDetectListeners are registered</li>
116
   * </ul>
126
   * </ul>
117
   *
127
   *
118
   * @param control the control whose parameters to preserve
128
   * @param control the control whose parameters to preserve
Lines 155-160 Link Here
155
    adapter.preserve( PROP_TRAVERSE_LISTENER,
165
    adapter.preserve( PROP_TRAVERSE_LISTENER,
156
                      Boolean.valueOf( TraverseEvent.hasListener( control ) ) );
166
                      Boolean.valueOf( TraverseEvent.hasListener( control ) ) );
157
    WidgetLCAUtil.preserveHelpListener( control );
167
    WidgetLCAUtil.preserveHelpListener( control );
168
    preserveMenuDetectListener( control );
158
  }
169
  }
159
170
160
  /**
171
  /**
Lines 294-299 Link Here
294
    writeKeyListener( control );
305
    writeKeyListener( control );
295
    writeTraverseListener( control );
306
    writeTraverseListener( control );
296
    writeKeyEventResponse( control );
307
    writeKeyEventResponse( control );
308
    writeMenuDetectListener( control );
297
    WidgetLCAUtil.writeHelpListener( control );
309
    WidgetLCAUtil.writeHelpListener( control );
298
  }
310
  }
299
311
Lines 589-594 Link Here
589
    }
601
    }
590
  }
602
  }
591
603
604
  ///////////////////////
605
  // Menu Detect Listener
606
607
  /**
608
   * Preserves whether the given <code>widget</code> has one or more
609
   * <code>MenuDetect</code>s attached.
610
   *
611
   * @param control the widget to preserve
612
   * @since 1.3
613
   */
614
  public static void preserveMenuDetectListener( final Control control ) {
615
    IWidgetAdapter adapter = WidgetUtil.getAdapter( control );
616
    boolean hasListener = MenuDetectEvent.hasListener( control );
617
    adapter.preserve( PROP_MENU_DETECT_LISTENER,
618
                      Boolean.valueOf( hasListener ) );
619
  }
620
621
  
622
  /**
623
   * Adds or removes client-side menu detect listeners for the the given
624
   * <code>control</code> as necessary.
625
   *
626
   * @param control
627
   * @since 1.3
628
   */
629
  public static void writeMenuDetectListener( final Control control )
630
    throws IOException
631
  {
632
    boolean hasListener = MenuDetectEvent.hasListener( control );
633
    JSWriter writer = JSWriter.getWriterFor( control );
634
    writer.updateListener( MENU_DETECT_LISTENER_INFO_MOUSE,
635
                           PROP_MENU_DETECT_LISTENER,
636
                           hasListener );
637
    writer.updateListener( MENU_DETECT_LISTENER_INFO_KEY,
638
                           PROP_MENU_DETECT_LISTENER,
639
                           hasListener );
640
  }
641
642
  /**
643
   * Process a <code>HelpEvent</code> if the current request specifies that
644
   * there occured a help event for the given <code>widget</code>.
645
   *
646
   * @param control the control to process
647
   * @since 1.3
648
   */
649
  public static void processMenuDetect( final Control control ) {
650
    if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MENU_DETECT ) ) {
651
      MenuDetectEvent event = new MenuDetectEvent( control );
652
      Point point = readXYParams( control,
653
                                  JSConst.EVENT_MENU_DETECT_X,
654
                                  JSConst.EVENT_MENU_DETECT_Y );
655
      point = control.getDisplay().map( control, null, point );
656
      event.x = point.x;
657
      event.y = point.y;
658
      event.processEvent();
659
    }
660
  }
661
592
  //////////
662
  //////////
593
  // Z-Index
663
  // Z-Index
594
664
(-)src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java (+1 lines)
Lines 56-61 Link Here
56
    processSelectionEvent( link );
56
    processSelectionEvent( link );
57
    ControlLCAUtil.processMouseEvents( link );
57
    ControlLCAUtil.processMouseEvents( link );
58
    ControlLCAUtil.processKeyEvents( link );
58
    ControlLCAUtil.processKeyEvents( link );
59
    ControlLCAUtil.processMenuDetect( link );
59
    WidgetLCAUtil.processHelp( link );
60
    WidgetLCAUtil.processHelp( link );
60
  }
61
  }
61
62
(-)src/org/eclipse/swt/internal/widgets/scalekit/ScaleLCA.java (+1 lines)
Lines 64-69 Link Here
64
    }
64
    }
65
    ControlLCAUtil.processSelection( scale, null, true );
65
    ControlLCAUtil.processSelection( scale, null, true );
66
    ControlLCAUtil.processKeyEvents( scale );
66
    ControlLCAUtil.processKeyEvents( scale );
67
    ControlLCAUtil.processMenuDetect( scale );
67
    WidgetLCAUtil.processHelp( scale );
68
    WidgetLCAUtil.processHelp( scale );
68
  }
69
  }
69
70
(-)src/org/eclipse/swt/internal/widgets/sliderkit/SliderLCA.java (+1 lines)
Lines 67-72 Link Here
67
      slider.setSelection( Integer.parseInt( value ) );
67
      slider.setSelection( Integer.parseInt( value ) );
68
    }
68
    }
69
    ControlLCAUtil.processSelection( slider, null, true );
69
    ControlLCAUtil.processSelection( slider, null, true );
70
    ControlLCAUtil.processMenuDetect( slider );
70
    WidgetLCAUtil.processHelp( slider );
71
    WidgetLCAUtil.processHelp( slider );
71
  }
72
  }
72
73

Return to bug 290303