@@ -29,24 +29,14 @@ markerSize _marker params ["_sizeA", "_sizeB"];
29
29
30
30
private _ctrl = _ctrlConfigure controlsGroupCtrl _idc ;
31
31
_ctrl ctrlSetText str _value ;
32
-
33
- _ctrl ctrlAddEventHandler [" KeyDown" , {
34
- params [" _ctrl" ];
35
-
36
- private _value = ctrlText _ctrl ;
37
- private _filter = toArray " .-0123456789" ;
38
- _value = toString (toArray _value select {_x in _filter });
39
-
40
- _ctrl ctrlSetText _value ;
41
- }];
42
32
} forEach [
43
33
[IDC_CONFIGURE_SIZE_A, _sizeA ],
44
34
[IDC_CONFIGURE_SIZE_B, _sizeB ]
45
35
];
46
36
47
37
private _ctrlRotationSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ROTATION_SLIDER;
48
38
private _ctrlRotationEdit = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ROTATION_EDIT;
49
- [_ctrlRotationSlider , _ctrlRotationEdit , 0 , 360 , markerDir _marker , 15 , { format [ " %1%2 " , round _this , toString [ASCII_DEGREE]]} ] call EFUNC(common,initSliderEdit);
39
+ [_ctrlRotationSlider , _ctrlRotationEdit , 0 , 360 , markerDir _marker , 15 , EFUNC(common,formatDegrees) ] call EFUNC(common,initSliderEdit);
50
40
51
41
private _ctrlShape = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SHAPE;
52
42
_ctrlShape lbSetCurSel ([" RECTANGLE" , " ELLIPSE" ] find markerShape _marker );
@@ -123,51 +113,42 @@ _ctrlButtonOK ctrlAddEventHandler ["ButtonClick", {
123
113
124
114
// Special handling for keyboard input when edit boxes have focus
125
115
// Needed to prevent interaction with Zeus display but still allow keyboard use with edit boxes
126
- {
127
- private _ctrl = _ctrlConfigure controlsGroupCtrl _x ;
128
-
129
- _ctrl ctrlAddEventHandler [" SetFocus" , {
130
- params [" _ctrl" ];
131
-
132
- private _ctrlConfigure = ctrlParent _ctrl displayCtrl IDC_CONFIGURE_GROUP;
133
- _ctrlConfigure setVariable [QGVAR(focus), _ctrl ];
134
- }];
135
-
136
- _ctrl ctrlAddEventHandler [" SetFocus" , {
137
- params [" _ctrl" ];
138
-
139
- private _ctrlConfigure = ctrlParent _ctrl displayCtrl IDC_CONFIGURE_GROUP;
140
- _ctrlConfigure setVariable [QGVAR(focus), nil ];
141
- }];
142
- } forEach [
143
- IDC_CONFIGURE_SIZE_A,
144
- IDC_CONFIGURE_SIZE_B,
145
- IDC_CONFIGURE_ROTATION_EDIT,
146
- IDC_CONFIGURE_ALPHA_EDIT
147
- ];
148
-
149
116
private _keyDownEH = _display displayAddEventHandler [" KeyDown" , {
150
117
call {
151
- params [" _display" , " _keyCode" ];
118
+ params [" _display" , " _keyCode" , " " , " _ctrl " ];
152
119
153
120
if (_keyCode in [DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT]) exitWith {false };
154
121
155
122
if (_keyCode in [DIK_BACKSPACE, DIK_DELETE]) then {
156
- private _ctrlConfigure = _display displayCtrl IDC_CONFIGURE_GROUP;
157
- private _ctrlEdit = _ctrlConfigure getVariable QGVAR(focus);
158
- if (isNil " _ctrlEdit" ) exitWith {};
159
-
160
- private _text = ctrlText _ctrlEdit ;
161
-
162
- if (_keyCode == DIK_BACKSPACE) then {
163
- _text = _text select [0 , count _text - 1 ];
123
+ private _ctrlEdit = focusedCtrl _display ;
124
+
125
+ if (ctrlIDC _ctrlEdit in IDCS_CONFIGURE_EDIT_BOXES) then {
126
+ ctrlTextSelection _ctrlEdit params [" _start" , " _length" ];
127
+
128
+ // Update length based on key to delete individual characters without selecting them
129
+ if (_length == 0 ) then {
130
+ _length = [1 , - 1 ] select (_keyCode == DIK_BACKSPACE);
131
+ };
132
+
133
+ // Get the selection start position from the left-hand side when the selection is made from right to left
134
+ if (_length < 0 ) then {
135
+ _start = _start + _length ;
136
+ };
137
+
138
+ // Delete the selected characters and update the edit box's text and selection
139
+ private _characters = toArray ctrlText _ctrlEdit ;
140
+ _characters deleteRange [_start , abs _length ];
141
+ _ctrlEdit ctrlSetText toString _characters ;
142
+ _ctrlEdit ctrlSetTextSelection [_start , 0 ];
164
143
};
144
+ };
165
145
166
- if (_keyCode == DIK_DELETE) then {
167
- _text = _text select [1 , count _text - 1 ];
168
- };
146
+ if (_keyCode == DIK_A && {_ctrl }) then {
147
+ private _ctrlEdit = focusedCtrl _display ;
169
148
170
- _ctrlEdit ctrlSetText _text ;
149
+ if (ctrlIDC _ctrlEdit in IDCS_CONFIGURE_EDIT_BOXES) then {
150
+ _ctrlEdit ctrlSetTextSelection [0 , count toArray ctrlText _ctrlEdit ];
151
+ };
171
152
};
172
153
173
154
if (_keyCode in [DIK_ESCAPE, DIK_RETURN]) then {
0 commit comments