Skip to content

Commit 5c85f1d

Browse files
avm2: Use accessors instead of fields for GestureEvent properties
1 parent f96e9ad commit 5c85f1d

File tree

2 files changed

+78
-13
lines changed

2 files changed

+78
-13
lines changed

core/src/avm2/globals/flash/events/GestureEvent.as

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,39 @@
44
// It won't be regenerated in the future, so feel free to edit and/or fix
55
package flash.events
66
{
7-
7+
[API("667")]
88
public class GestureEvent extends Event
99
{
1010
public static const GESTURE_TWO_FINGER_TAP:String = "gestureTwoFingerTap"; // Defines the value of the type property of a GESTURE_TWO_FINGER_TAP gesture event object.
1111

1212
// A value from the GesturePhase class indicating the progress of the touch gesture.
13-
public var phase: String;
13+
private var _phase: String;
1414

1515
// The horizontal coordinate at which the event occurred relative to the containing sprite.
1616
[Ruffle(NativeAccessible)]
17-
public var localX: Number;
17+
private var _localX: Number;
1818

1919
// The vertical coordinate at which the event occurred relative to the containing sprite.
2020
[Ruffle(NativeAccessible)]
21-
public var localY: Number;
21+
private var _localY: Number;
2222

2323
// On Windows or Linux, indicates whether the Ctrl key is active (true) or inactive (false).
24-
public var ctrlKey: Boolean;
24+
private var _ctrlKey: Boolean;
2525

2626
// Indicates whether the Alt key is active (true) or inactive (false).
27-
public var altKey: Boolean;
27+
private var _altKey: Boolean;
2828

2929
// Indicates whether the Shift key is active (true) or inactive (false).
30-
public var shiftKey: Boolean;
30+
private var _shiftKey: Boolean;
31+
32+
// On a Mac OS, the value of the commandKey property is the same value as the ctrlKey property. This property is always false on Windows or Linux.
33+
private var _commandKey: Boolean;
3134

3235
// Indicates whether the Control key is activated on Mac and whether the Ctrl key is activated on Windows or Linux.
33-
public var controlKey: Boolean;
36+
private var _controlKey: Boolean;
3437

3538
public function GestureEvent(type:String, bubbles:Boolean = true, cancelable:Boolean = false, phase:String = null, localX:Number = 0,
36-
localY:Number = 0, ctrlKey:Boolean = false, altKey:Boolean = false, shiftKey:Boolean = false, controlKey:Boolean = false)
39+
localY:Number = 0, ctrlKey:Boolean = false, altKey:Boolean = false, shiftKey:Boolean = false, commandKey:Boolean = false, controlKey:Boolean = false)
3740
{
3841
super(type,bubbles,cancelable);
3942
this.phase = phase;
@@ -42,9 +45,71 @@ package flash.events
4245
this.ctrlKey = ctrlKey;
4346
this.altKey = altKey;
4447
this.shiftKey = shiftKey;
48+
this.commandKey = commandKey;
4549
this.controlKey = controlKey;
4650
}
47-
51+
52+
public function get phase():String {
53+
return this._phase;
54+
}
55+
public function set phase(value:String):void {
56+
this._phase = value;
57+
}
58+
59+
public function get localX():Number {
60+
return this._localX;
61+
}
62+
public function set localX(value:Number):void {
63+
this._localX = value;
64+
}
65+
66+
public function get localY():Number {
67+
return this._localY;
68+
}
69+
public function set localY(value:Number):void {
70+
this._localY = value;
71+
}
72+
73+
public function get ctrlKey():Boolean {
74+
return this._ctrlKey;
75+
}
76+
public function set ctrlKey(value:Boolean):void {
77+
this._ctrlKey = value;
78+
}
79+
80+
public function get altKey():Boolean {
81+
return this._altKey;
82+
}
83+
public function set altKey(value:Boolean):void {
84+
this._altKey = value;
85+
}
86+
87+
public function get shiftKey():Boolean {
88+
return this._shiftKey;
89+
}
90+
public function set shiftKey(value:Boolean):void {
91+
this._shiftKey = value;
92+
}
93+
94+
// commandKey and controlKey are AIR-only
95+
96+
[API("668")]
97+
public function get commandKey():Boolean {
98+
return this._commandKey;
99+
}
100+
[API("668")]
101+
public function set commandKey(value:Boolean):void {
102+
this._commandKey = value;
103+
}
104+
105+
[API("668")]
106+
public function get controlKey():Boolean {
107+
return this._controlKey;
108+
}
109+
[API("668")]
110+
public function set controlKey(value:Boolean):void {
111+
this._controlKey = value;
112+
}
48113

49114
// Creates a copy of the GestureEvent object and sets the value of each property to match that of the original.
50115
override public function clone():Event
@@ -55,7 +120,7 @@ package flash.events
55120
// Returns a string that contains all the properties of the GestureEvent object.
56121
override public function toString():String
57122
{
58-
return this.formatToString("GestureEvent","type","bubbles","cancelable","eventPhase","phase","localX","localY","ctrlKey","altKey","shiftKey","commandKey","controlKey","stageX","stageY");
123+
return this.formatToString("GestureEvent","type","bubbles","cancelable","phase","localX","localY","stageX","stageY","ctrlKey","altKey","shiftKey");
59124
}
60125

61126
// The horizontal coordinate at which the event occurred in global Stage coordinates.

core/src/avm2/globals/flash/events/gesture_event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn get_stage_x<'gc>(
1111
) -> Result<Value<'gc>, Error<'gc>> {
1212
let this = this.as_object().unwrap();
1313

14-
mouse_event::local_to_stage_x(activation, this, slots::LOCAL_X, slots::LOCAL_Y)
14+
mouse_event::local_to_stage_x(activation, this, slots::_LOCAL_X, slots::_LOCAL_Y)
1515
}
1616

1717
pub fn get_stage_y<'gc>(
@@ -21,5 +21,5 @@ pub fn get_stage_y<'gc>(
2121
) -> Result<Value<'gc>, Error<'gc>> {
2222
let this = this.as_object().unwrap();
2323

24-
mouse_event::local_to_stage_y(activation, this, slots::LOCAL_X, slots::LOCAL_Y)
24+
mouse_event::local_to_stage_y(activation, this, slots::_LOCAL_X, slots::_LOCAL_Y)
2525
}

0 commit comments

Comments
 (0)