View | Details | Raw Unified | Return to bug 81334 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java (+55 lines)
Lines 109-114 Link Here
109
	addListener (SWT.DefaultSelection,typedListener);
109
	addListener (SWT.DefaultSelection,typedListener);
110
}
110
}
111
111
112
/**
113
 * Adds the listener to the collection of listeners who will
114
 * be notified when the platform-specific context menu trigger
115
 * has occurred, by sending it one of the messages defined in
116
 * the <code>MenuDetectListener</code> interface.
117
 *
118
 * @param listener the listener which should be notified
119
 *
120
 * @exception IllegalArgumentException <ul>
121
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
122
 * </ul>
123
 * @exception SWTException <ul>
124
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
125
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
126
 * </ul>
127
 *
128
 * @see MenuDetectListener
129
 * @see #removeMenuDetectListener
130
 *
131
 * @since 3.3
132
 */
133
public void addMenuDetectListener (MenuDetectListener listener) {
134
	checkWidget ();
135
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
136
	TypedListener typedListener = new TypedListener (listener);
137
	addListener (SWT.MenuDetect, typedListener);
138
}
139
112
protected void checkSubclass () {
140
protected void checkSubclass () {
113
	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
141
	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
114
}
142
}
Lines 322-327 Link Here
322
}
350
}
323
351
324
/**
352
/**
353
 * Removes the listener from the collection of listeners who will
354
 * be notified when the platform-secific context menu trigger has
355
 * occurred.
356
 *
357
 * @param listener the listener which should no longer be notified
358
 *
359
 * @exception IllegalArgumentException <ul>
360
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
361
 * </ul>
362
 * @exception SWTException <ul>
363
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
364
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
365
 * </ul>
366
 *
367
 * @see MenuDetectListener
368
 * @see #addMenuDetectListener
369
 *
370
 * @since 3.3
371
 */
372
public void removeMenuDetectListener (MenuDetectListener listener) {
373
	checkWidget ();
374
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
375
	if (eventTable == null) return;
376
	eventTable.unhook (SWT.MenuDetect, listener);
377
}
378
379
/**
325
 * Sets the receiver's image.
380
 * Sets the receiver's image.
326
 *
381
 *
327
 * @param image the new image
382
 * @param image the new image
(-)Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java (+109 lines)
Lines 245-250 Link Here
245
245
246
/**
246
/**
247
 * Adds the listener to the collection of listeners who will
247
 * Adds the listener to the collection of listeners who will
248
 * be notified when the platform-specific context menu trigger
249
 * has occurred, by sending it one of the messages defined in
250
 * the <code>MenuDetectListener</code> interface.
251
 *
252
 * @param listener the listener which should be notified
253
 *
254
 * @exception IllegalArgumentException <ul>
255
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
256
 * </ul>
257
 * @exception SWTException <ul>
258
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
259
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
260
 * </ul>
261
 *
262
 * @see MenuDetectListener
263
 * @see #removeMenuDetectListener
264
 *
265
 * @since 3.3
266
 */
267
public void addMenuDetectListener (MenuDetectListener listener) {
268
	checkWidget ();
269
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
270
	TypedListener typedListener = new TypedListener (listener);
271
	addListener (SWT.MenuDetect, typedListener);
272
}
273
274
/**
275
 * Adds the listener to the collection of listeners who will
248
 * be notified when mouse buttons are pressed and released, by sending
276
 * be notified when mouse buttons are pressed and released, by sending
249
 * it one of the messages defined in the <code>MouseListener</code>
277
 * it one of the messages defined in the <code>MouseListener</code>
250
 * interface.
278
 * interface.
Lines 327-332 Link Here
327
355
328
/**
356
/**
329
 * Adds the listener to the collection of listeners who will
357
 * Adds the listener to the collection of listeners who will
358
 * be notified when the mouse wheel is scrolled, by sending
359
 * it one of the messages defined in the
360
 * <code>MouseWheelListener</code> interface.
361
 *
362
 * @param listener the listener which should be notified
363
 *
364
 * @exception IllegalArgumentException <ul>
365
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
366
 * </ul>
367
 * @exception SWTException <ul>
368
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
369
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
370
 * </ul>
371
 *
372
 * @see MouseWheelListener
373
 * @see #removeMouseWheelListener
374
 *
375
 * @since 3.3
376
 */
377
public void addMouseWheelListener (MouseWheelListener listener) {
378
	checkWidget ();
379
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
380
	TypedListener typedListener = new TypedListener (listener);
381
	addListener (SWT.MouseWheel, typedListener);
382
}
383
384
/**
385
 * Adds the listener to the collection of listeners who will
330
 * be notified when the receiver needs to be painted, by sending it
386
 * be notified when the receiver needs to be painted, by sending it
331
 * one of the messages defined in the <code>PaintListener</code>
387
 * one of the messages defined in the <code>PaintListener</code>
332
 * interface.
388
 * interface.
Lines 2047-2052 Link Here
2047
2103
2048
/**
2104
/**
2049
 * Removes the listener from the collection of listeners who will
2105
 * Removes the listener from the collection of listeners who will
2106
 * be notified when the platform-secific context menu trigger has
2107
 * occurred.
2108
 *
2109
 * @param listener the listener which should no longer be notified
2110
 *
2111
 * @exception IllegalArgumentException <ul>
2112
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
2113
 * </ul>
2114
 * @exception SWTException <ul>
2115
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
2116
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
2117
 * </ul>
2118
 *
2119
 * @see MenuDetectListener
2120
 * @see #addMenuDetectListener
2121
 *
2122
 * @since 3.3
2123
 */
2124
public void removeMenuDetectListener (MenuDetectListener listener) {
2125
	checkWidget ();
2126
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
2127
	if (eventTable == null) return;
2128
	eventTable.unhook (SWT.MenuDetect, listener);
2129
}
2130
2131
/**
2132
 * Removes the listener from the collection of listeners who will
2050
 * be notified when the mouse passes or hovers over controls.
2133
 * be notified when the mouse passes or hovers over controls.
2051
 *
2134
 *
2052
 * @param listener the listener which should no longer be notified
2135
 * @param listener the listener which should no longer be notified
Lines 2123-2128 Link Here
2123
2206
2124
/**
2207
/**
2125
 * Removes the listener from the collection of listeners who will
2208
 * Removes the listener from the collection of listeners who will
2209
 * be notified when the mouse wheel is scrolled.
2210
 *
2211
 * @param listener the listener which should no longer be notified
2212
 *
2213
 * @exception IllegalArgumentException <ul>
2214
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
2215
 * </ul>
2216
 * @exception SWTException <ul>
2217
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
2218
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
2219
 * </ul>
2220
 *
2221
 * @see MouseWheelListener
2222
 * @see #addMouseWheelListener
2223
 *
2224
 * @since 3.3
2225
 */
2226
public void removeMouseWheelListener (MouseWheelListener listener) {
2227
	checkWidget ();
2228
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
2229
	if (eventTable == null) return;
2230
	eventTable.unhook (SWT.MouseWheel, listener);
2231
}
2232
2233
/**
2234
 * Removes the listener from the collection of listeners who will
2126
 * be notified when the receiver needs to be painted.
2235
 * be notified when the receiver needs to be painted.
2127
 *
2236
 *
2128
 * @param listener the listener which should no longer be notified
2237
 * @param listener the listener which should no longer be notified
(-)Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java (+12 lines)
Lines 166-171 Link Here
166
			((ModifyListener) eventListener).modifyText(new ModifyEvent(e));
166
			((ModifyListener) eventListener).modifyText(new ModifyEvent(e));
167
			break;
167
			break;
168
		}
168
		}
169
		case SWT.MenuDetect: {
170
			MenuDetectEvent event = new MenuDetectEvent(e);
171
			((MenuDetectListener) eventListener).menuDetected(event);
172
			e.x = event.x;
173
			e.y = event.y;
174
			e.doit = event.doit;
175
			break;
176
		}
169
		case SWT.MouseDown: {
177
		case SWT.MouseDown: {
170
			((MouseListener) eventListener).mouseDown(new MouseEvent(e));
178
			((MouseListener) eventListener).mouseDown(new MouseEvent(e));
171
			break;
179
			break;
Lines 190-195 Link Here
190
			((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
198
			((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
191
			return;
199
			return;
192
		}
200
		}
201
		case SWT.MouseWheel: {
202
			((MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e));
203
			return;
204
		}
193
		case SWT.MouseUp: {
205
		case SWT.MouseUp: {
194
			((MouseListener) eventListener).mouseUp(new MouseEvent(e));
206
			((MouseListener) eventListener).mouseUp(new MouseEvent(e));
195
			break;
207
			break;
(-)Eclipse (+41 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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.swt.internal.SWTEventListener;
15
16
/**
17
 * Classes which implement this interface provide a method
18
 * that deals with the event that is generated as the mouse
19
 * wheel is scrolled.
20
 * <p>
21
 * After creating an instance of a class that implements
22
 * this interface it can be added to a control using the
23
 * <code>addMouseWheelListener</code> method and removed using
24
 * the <code>removeMouseWheelListener</code> method. When the
25
 * mouse wheel is scrolled the <code>mouseScrolled</code> method
26
 * will be invoked.
27
 * </p>
28
 *
29
 * @see MouseEvent
30
 *
31
 * @since 3.3
32
 */
33
public interface MouseWheelListener extends SWTEventListener {
34
35
/**
36
 * Sent when the mouse wheel is scrolled.
37
 *
38
 * @param e an event containing information about the mouse wheel action
39
 */
40
public void mouseScrolled (MouseEvent e);	
41
}
(-)Eclipse (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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.swt.widgets.Event;
15
16
/**
17
 * Instances of this class are sent whenever the platform-
18
 * specific trigger for showing a context menu is detected.
19
 *
20
 * @see MenuDetectListener
21
 *
22
 * @since 3.3
23
 */
24
25
public final class MenuDetectEvent extends TypedEvent {
26
27
	/**
28
	 * the widget-relative, x coordinate of the pointer
29
	 * at the time the context menu trigger occurred
30
	 */
31
	public int x;
32
	
33
	/**
34
	 * the widget-relative, y coordinate of the pointer
35
	 * at the time the context menu trigger occurred
36
	 */	
37
	public int y;
38
	
39
	/**
40
	 * A flag indicating whether the operation should be allowed.
41
	 * Setting this field to <code>false</code> will cancel the operation.
42
	 */
43
	public boolean doit;
44
45
	private static final long serialVersionUID = -3061660596590828941L;
46
47
/**
48
 * Constructs a new instance of this class based on the
49
 * information in the given untyped event.
50
 *
51
 * @param e the untyped event containing the information
52
 */
53
public MenuDetectEvent(Event e) {
54
	super(e);
55
	this.x = e.x;
56
	this.y = e.y;
57
	this.doit = e.doit;
58
}
59
60
/**
61
 * Returns a string containing a concise, human-readable
62
 * description of the receiver.
63
 *
64
 * @return a string representation of the event
65
 */
66
public String toString() {
67
	String string = super.toString ();
68
	return string.substring (0, string.length() - 1) // remove trailing '}'
69
		+ " x=" + x
70
		+ " y=" + y
71
		+ " doit=" + doit
72
		+ "}";
73
}
74
}
(-)Eclipse (+42 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 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.swt.internal.SWTEventListener;
15
16
/**
17
 * Classes which implement this interface provide methods
18
 * that deal with the events that are generated when the
19
 * platform-specific trigger for showing a context menu is
20
 * detected.
21
 * <p>
22
 * After creating an instance of a class that implements
23
 * this interface it can be added to a control or TrayItem
24
 * using the <code>addMenuDetectListener</code> method and
25
 * removed using the <code>removeMenuDetectListener</code> method.
26
 * When the context menu trigger occurs, the
27
 * <code>menuDetected</code> method will be invoked.
28
 * </p>
29
 *
30
 * @see MenuDetectEvent
31
 *
32
 * @since 3.3
33
 */
34
public interface MenuDetectListener extends SWTEventListener {
35
36
/**
37
 * Sent when the platform-dependent trigger for showing a menu item is detected.
38
 *
39
 * @param e an event containing information about the menu detect
40
 */
41
public void menuDetected (MenuDetectEvent e);
42
}

Return to bug 81334