Package org.eclipse.swt.widgets
Class Event
- java.lang.Object
-
- org.eclipse.swt.widgets.Event
-
public class Event extends Object
Instances of this class provide a description of a particular event which occurred within SWT. The SWT untyped listener API uses these instances for all event dispatching.Note: For a given event, only the fields which are appropriate will be filled in. The contents of the fields which are not used by the event are unspecified.
-
-
Field Summary
Fields Modifier and Type Field Description int
button
the button that was pressed or released; 1 for the first button, 2 for the second button, and 3 for the third button, etc.char
character
depending on the event, the character represented by the key that was typed.int
count
depending on the event type, the number of following paint events that are pending which may always be zero on some platforms, or the number of lines or pages to scroll using the mouse wheel, or the number of times the mouse has been clickedObject
data
a field for application useint
detail
the event specific detail field, as defined by the detail constants in classSWT
Display
display
the display where the event occurredboolean
doit
depending on the event, a flag indicating whether the operation should be allowed.int
end
depending on the event, the range of text being modified.GC
gc
the graphics context to use when painting that is configured to use the colors, font and damaged region of the control.int
height
the height of the bounding rectangle of the region that requires paintingint
index
the index of the item where the event occurredWidget
item
the item that the event occurred in (can be null)int
keyCode
depending on the event, the key code of the key that was typed, as defined by the key code constants in classSWT
.int
keyLocation
depending on the event, the location of key specified by the keyCode or character.double
magnification
The change in magnification.double
rotation
The number of degrees rotated on the track pad.int[]
segments
Bidi segment offsetschar[]
segmentsChars
Characters to be applied on the segment boundariesint
start
depending on the event, the range of text being modified.int
stateMask
depending on the event, the state of the keyboard modifier keys and mouse masks at the time the event was generated.String
text
depending on the event, the new text that will be inserted.int
time
the time that the event occurred.Touch[]
touches
An array of the touch states for the current touch event.int
type
the type of event, as defined by the event type constants in classSWT
Widget
widget
the widget that issued the eventint
width
the width of the bounding rectangle of the region that requires paintingint
x
depending on the event type, the x offset of the bounding rectangle of the region that requires painting or the widget-relative, x coordinate of the pointer at the time the mouse button was pressed or releasedint
xDirection
If nonzero, a positive value indicates a swipe to the right, and a negative value indicates a swipe to the left.int
y
depending on the event type, the y offset of the bounding rectangle of the region that requires painting or the widget-relative, y coordinate of the pointer at the time the mouse button was pressed or releasedint
yDirection
If nonzero, a positive value indicates a swipe in the up direction, and a negative value indicates a swipe in the down direction.
-
Constructor Summary
Constructors Constructor Description Event()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rectangle
getBounds()
Gets the bounds.void
setBounds(Rectangle rect)
Sets the bounds.String
toString()
Returns a string containing a concise, human-readable description of the receiver.
-
-
-
Field Detail
-
display
public Display display
the display where the event occurred- Since:
- 2.0
-
widget
public Widget widget
the widget that issued the event
-
type
public int type
the type of event, as defined by the event type constants in classSWT
- See Also:
SWT
-
detail
public int detail
the event specific detail field, as defined by the detail constants in classSWT
- See Also:
SWT
-
item
public Widget item
the item that the event occurred in (can be null)
-
index
public int index
the index of the item where the event occurred- Since:
- 3.2
-
gc
public GC gc
the graphics context to use when painting that is configured to use the colors, font and damaged region of the control. It is valid only during the paint and must not be disposed
-
x
public int x
depending on the event type, the x offset of the bounding rectangle of the region that requires painting or the widget-relative, x coordinate of the pointer at the time the mouse button was pressed or released
-
y
public int y
depending on the event type, the y offset of the bounding rectangle of the region that requires painting or the widget-relative, y coordinate of the pointer at the time the mouse button was pressed or released
-
width
public int width
the width of the bounding rectangle of the region that requires painting
-
height
public int height
the height of the bounding rectangle of the region that requires painting
-
count
public int count
depending on the event type, the number of following paint events that are pending which may always be zero on some platforms, or the number of lines or pages to scroll using the mouse wheel, or the number of times the mouse has been clicked
-
time
public int time
the time that the event occurred. NOTE: This field is an unsigned integer and should be AND'ed with 0xFFFFFFFFL so that it can be treated as a signed long.
-
button
public int button
the button that was pressed or released; 1 for the first button, 2 for the second button, and 3 for the third button, etc.
-
character
public char character
depending on the event, the character represented by the key that was typed. This is the final character that results after all modifiers have been applied. For example, when the user types Ctrl+A, the character value is 0x01 (ASCII SOH). It is important that applications do not attempt to modify the character value based on a stateMask (such as SWT.CTRL) or the resulting character will not be correct.
-
keyCode
public int keyCode
depending on the event, the key code of the key that was typed, as defined by the key code constants in classSWT
. When the character field of the event is ambiguous, this field contains the unaffected value of the original character. For example, typing Ctrl+M or Enter both result in the character '\r' but the keyCode field will also contain '\r' when Enter was typed and 'm' when Ctrl+M was typed.- See Also:
SWT
-
keyLocation
public int keyLocation
depending on the event, the location of key specified by the keyCode or character. The possible values for this field areSWT.LEFT
,SWT.RIGHT
,SWT.KEYPAD
, orSWT.NONE
representing the main keyboard area.The location field can be used to differentiate key events that have the same key code and character but are generated by different keys in the keyboard. For example, a key down event with the key code equals to SWT.SHIFT can be generated by the left and the right shift keys in the keyboard. The location field can only be used to determine the location of the key code or character in the current event. It does not include information about the location of modifiers in state mask.
- Since:
- 3.6
- See Also:
SWT.LEFT
,SWT.RIGHT
,SWT.KEYPAD
-
stateMask
public int stateMask
depending on the event, the state of the keyboard modifier keys and mouse masks at the time the event was generated.- See Also:
SWT.MODIFIER_MASK
,SWT.BUTTON_MASK
-
start
public int start
depending on the event, the range of text being modified. Setting these fields only has effect during ImeComposition events.
-
end
public int end
depending on the event, the range of text being modified. Setting these fields only has effect during ImeComposition events.
-
text
public String text
depending on the event, the new text that will be inserted. Setting this field will change the text that is about to be inserted or deleted.
-
segments
public int[] segments
Bidi segment offsets- Since:
- 3.8
-
segmentsChars
public char[] segmentsChars
Characters to be applied on the segment boundaries- Since:
- 3.8
-
doit
public boolean doit
depending on the event, a flag indicating whether the operation should be allowed. Setting this field to false will cancel the operation.
-
data
public Object data
a field for application use
-
touches
public Touch[] touches
An array of the touch states for the current touch event.- Since:
- 3.7
-
xDirection
public int xDirection
If nonzero, a positive value indicates a swipe to the right, and a negative value indicates a swipe to the left.- Since:
- 3.7
-
yDirection
public int yDirection
If nonzero, a positive value indicates a swipe in the up direction, and a negative value indicates a swipe in the down direction.- Since:
- 3.7
-
magnification
public double magnification
The change in magnification. This value should be added to the current scaling of an item to get the new scale factor.- Since:
- 3.7
-
rotation
public double rotation
The number of degrees rotated on the track pad.- Since:
- 3.7
-
-