]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/events/SelectionEvent.java
aa6bc87a2ab7f5a6a3719e50740940f4f1a88733
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / events / SelectionEvent.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  *
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/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.events;
15
16
17 import org.eclipse.swt.widgets.*;
18
19 /**
20  * Instances of this class are sent as a result of
21  * widgets being selected.
22  * <p>
23  * Note: The fields that are filled in depend on the widget.
24  * </p>
25  *
26  * @see SelectionListener
27  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
28  */
29
30 public class SelectionEvent extends TypedEvent {
31
32         /**
33          * The item that was selected.
34          */
35         public Widget item;
36
37         /**
38          * Extra detail information about the selection, depending on the widget.
39          *
40          * <p><b>Sash</b></p>
41          * <ul>
42          * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
43          * </ul>
44          * <p><b>ScrollBar and Slider</b></p>
45          * <ul>
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>
53          * </ul>
54          * <p><b>Table and Tree</b></p>
55          * <ul>
56          * <li>{@link org.eclipse.swt.SWT#CHECK}</li>
57          * </ul>
58          * <p><b>Text</b></p>
59          * <ul>
60          * <li>{@link org.eclipse.swt.SWT#CANCEL}</li>
61          * </ul>
62          * <p><b>CoolItem and ToolItem</b></p>
63          * <ul>
64          * <li>{@link org.eclipse.swt.SWT#ARROW}</li>
65          * </ul>
66          */
67         public int detail;
68
69         /**
70          * The x location of the selected area.
71          */
72         public int x;
73
74         /**
75          * The y location of selected area.
76          */
77         public int y;
78
79         /**
80          * The width of selected area.
81          */
82         public int width;
83
84         /**
85          * The height of selected area.
86          */
87         public int height;
88
89         /**
90          * The state of the keyboard modifier keys and mouse masks
91          * at the time the event was generated.
92          * <p>
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.
96          * </p>
97          *
98          * @see org.eclipse.swt.SWT#MODIFIER_MASK
99          * @see org.eclipse.swt.SWT#BUTTON_MASK
100          */
101         public int stateMask;
102
103         /**
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.
107          *
108          * @see org.eclipse.swt.widgets.Link#setText(String)
109          * @since 3.1
110          */
111         public String text;
112
113         /**
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.
117          */
118         public boolean doit;
119
120         static final long serialVersionUID = 3976735856884987953L;
121
122 /**
123  * Constructs a new instance of this class based on the
124  * information in the given untyped event.
125  *
126  * @param e the untyped event containing the information
127  */
128 public SelectionEvent(Event e) {
129         super(e);
130         this.item = e.item;
131         this.x = e.x;
132         this.y = e.y;
133         this.width = e.width;
134         this.height = e.height;
135         this.detail = e.detail;
136         this.stateMask = e.stateMask;
137         this.text = e.text;
138         this.doit = e.doit;
139 }
140
141 /**
142  * Returns a string containing a concise, human-readable
143  * description of the receiver.
144  *
145  * @return a string representation of the event
146  */
147 @Override
148 public String toString() {
149         String string = super.toString ();
150         return string.substring (0, string.length() - 1) // remove trailing '}'
151                 + " item=" + item
152                 + " detail=" + detail
153                 + " x=" + x
154                 + " y=" + y
155                 + " width=" + width
156                 + " height=" + height
157                 + " stateMask=0x" + Integer.toHexString(stateMask)
158                 + " text=" + text
159                 + " doit=" + doit
160                 + "}";
161 }
162 }
163