1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.events;
17 import org.eclipse.swt.widgets.*;
20 * Instances of this class are sent as a result of
21 * widgets being selected.
23 * Note: The fields that are filled in depend on the widget.
26 * @see SelectionListener
27 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
30 public class SelectionEvent extends TypedEvent {
33 * The item that was selected.
38 * Extra detail information about the selection, depending on the widget.
42 * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
44 * <p><b>ScrollBar and Slider</b></p>
46 * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
47 * <li>{@link org.eclipse.swt.SWT#HOME}</li>
48 * <li>{@link org.eclipse.swt.SWT#END}</li>
49 * <li>{@link org.eclipse.swt.SWT#ARROW_DOWN}</li>
50 * <li>{@link org.eclipse.swt.SWT#ARROW_UP}</li>
51 * <li>{@link org.eclipse.swt.SWT#PAGE_DOWN}</li>
52 * <li>{@link org.eclipse.swt.SWT#PAGE_UP}</li>
54 * <p><b>Table and Tree</b></p>
56 * <li>{@link org.eclipse.swt.SWT#CHECK}</li>
60 * <li>{@link org.eclipse.swt.SWT#CANCEL}</li>
62 * <p><b>CoolItem and ToolItem</b></p>
64 * <li>{@link org.eclipse.swt.SWT#ARROW}</li>
70 * The x location of the selected area.
75 * The y location of selected area.
80 * The width of selected area.
85 * The height of selected area.
90 * The state of the keyboard modifier keys and mouse masks
91 * at the time the event was generated.
93 * <b>Note:</b> Mouse button states are currently not included consistently
94 * for all widgets on all platforms. Clients should be prepared to receive
95 * button states, but should not rely on getting them everywhere.
98 * @see org.eclipse.swt.SWT#MODIFIER_MASK
99 * @see org.eclipse.swt.SWT#BUTTON_MASK
101 public int stateMask;
104 * The text of the hyperlink that was selected.
105 * This will be either the text of the hyperlink or the value of its HREF,
106 * if one was specified.
108 * @see org.eclipse.swt.widgets.Link#setText(String)
114 * A flag indicating whether the operation should be allowed.
115 * Setting this field to <code>false</code> will cancel the
116 * operation, depending on the widget.
120 static final long serialVersionUID = 3976735856884987953L;
123 * Constructs a new instance of this class based on the
124 * information in the given untyped event.
126 * @param e the untyped event containing the information
128 public SelectionEvent(Event e) {
133 this.width = e.width;
134 this.height = e.height;
135 this.detail = e.detail;
136 this.stateMask = e.stateMask;
142 * Returns a string containing a concise, human-readable
143 * description of the receiver.
145 * @return a string representation of the event
148 public String toString() {
149 String string = super.toString ();
150 return string.substring (0, string.length() - 1) // remove trailing '}'
152 + " detail=" + detail
156 + " height=" + height
157 + " stateMask=0x" + Integer.toHexString(stateMask)