Hello,

voilà, j'ai un événement onMouseWheel et j'aimerais pouvoir en cliquant sur le trackbar considéré donner le focus à celui-ci de manière à ce que ce soit lui qui réagisse à cet événement et pas systématiquement la dernière instance de trackbar créé.

ci-joint le code pour voir le truc :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
 
unit Utrack;
 
interface
 
uses Flash8;
 
type
 
 TTrackcur=class(MovieClip)
 private
  autorisation:boolean;
 public
    xmin,xmax:number;
    orientation:string;
    xmouse,ymouse:number;
    trackmin,trackmax:integer;
    xcur,ycur:Integer;
    downcur:Boolean;
    Procedure dessin;
    constructor Create(AOWNER:Movieclip;trmin,trmax:integer);
    procedure onPress;override;
    procedure onMouseMove;override;
    procedure onMouseUp;override;
    procedure onRollOver;override;
    procedure onRollOut;override;
    procedure onMouseWheel(delta: Number; scrollTarget: TObject=nil);
  end;
 
 TTrackBar=Class(movieClip)
 private
  w,h:integer;
  position:number;
  bevel:BevelFilter;
  myfilterArray:TArray;
  cur: TTrackcur;
  function GetLeft:number;
  function Gettop:number;
  function Getwidth:number;
  function Getheight:number;
  function Getcolor:number;
  procedure Setleft(value:number);
  procedure SetTop(value:number);
  procedure SetWidth(value:number);
  procedure SetHeight(value:number);
  procedure Setcolor(value:number);
 public
  constructor Create(parent:movieclip);
  procedure onChange;virtual;
  procedure graduation;
  property Left:number read GetLeft write SetLeft;
  property Top:number read GetTop write SetTop;
  property width:number read GetWidth write SetWidth;
  property height:number read GetHeight write SetHeight;
  property color:number read GetColor write SetColor;
 end;
 
const
 distance=0.3; //La distance de décalage du biseau, en pixels
 angleInDegrees=45;// L'angle du biseau, de 0 à 360 degrés.
 highlightColor=$c0c0c0;//La couleur de soulignement du biseau
 highlightAlpha=0.8;  //sa transparence
 shadowColor=clblack; //La couleur d'ombre du biseau
 shadowAlpha=0.9; //sa transparence
 blurX=5;//le flou horizontal
 blurY=5; // le flou vertical
 strength=5;//L'intensité du recouvrement. entre 0 et 255.
 quality=3; //valeur 3 à une qualité élevée.
 typ='inner'; //Le type de biseau. Les valeurs valides sont inner ou outer
 
implementation
 
function arrondi(n:number):integer;
begin
  if n-trunc(n)<0.5 then result:=trunc(n) else result:=trunc(n)+1;
end;
 
constructor TTrackbar.Create(parent:movieclip);
var mc:movieclip;
begin
 inherited Create(parent,'Trackbar',movieclip(parent).getNextHighestDepth());
 w:=100;
 h:=20;
 left:=10;
 top:=10;
 color:=clred;
 bevel:=BevelFilter.create(distance,angleInDegrees,highlightColor,highlightAlpha,shadowColor,shadowAlpha,blurX,blurY,strength,quality,typ);
 myfilterArray:=TArray.Create();
 myfilterArray.Push(bevel);
 filters := myfilterArray;
 lineto(w,0);
 lineto(w,h);
 lineto(0,h);
 mc:=movieclip.create(self,'mc',0);
 with mc do
 begin
  filters := myfilterArray;
  beginFill(clcream);
  moveto(w/15,h/4);
  lineto(w-w/15,h/4);
  lineto(w-w/15,h/4+3);
  lineto(w/15,h/4+3);
  lineto(w/15,h/4);
  endFill();
  linestyle(1,$c0c0c0);
  moveto(w/15,h/4+5);
  lineto(w/15,h/4+5.5);
  moveto(w-w/15,h/4+5);
  lineto(w-w/15,h/4+5.5);
 end;
 cur:=TTrackcur.Create(self,0,100);
 with cur do
 begin
  _x:=w/15;
  _y:=h/3.3;
 end;
end;
 
procedure TTrackbar.Setleft(value:number);
begin
  _x:=value;
end;
 
procedure TTrackbar.SetTop(value:number);
begin
 _y:=value;
end;
 
procedure TTrackbar.SetWidth(value:number);
begin
 _xscale:=100*value/w;
 _yscale:=_xscale;
end;
 
procedure TTrackbar.SetHeight(value:number);
begin
 _yscale:=100*value/h;
end;
 
procedure TTrackbar.Setcolor(value:number);
begin
 opaqueBackground:=value;
end;
 
procedure TTrackbar.graduation;
var l,grad:number;
    i,nbgrad:integer;
begin
 l:=13*w/15;
 nbgrad:=cur.trackmax-cur.trackmin;
 grad:=l/nbgrad;
 linestyle(1,$c0c0c0);
 for i:=1 to  nbgrad do
 begin
  moveto(w/15+grad*i,h/4+5);
  lineto(w/15+grad*i,h/4+5.25);
 end;
end;
 
procedure TTrackbar.onChange;
begin
end;
 
Function TTrackbar.Getcolor:number;
begin
 result:=opaqueBackground;
end;
 
Function  TTrackbar.GetWidth:number;
begin
 result:=_width;
end;
 
Function  TTrackbar.Getheight:number;
begin
 result:=_height;
end;
 
Function  TTrackbar.GetLeft:number;
begin
 result:=_x;
end;
 
Function  TTrackbar.GetTop:number;
begin
 result:=_y;
end;
 
procedure  TTrackcur.onPress;
begin
 downcur:=true;
 xmouse:=_xmouse;
 ymouse:=_ymouse;
end;
 
procedure  TTrackcur.onMouseMove;
var tr:TTrackbar;
begin
 if  autorisation then
 begin
     tr:= TTrackbar(_parent);
     if downcur then
     if orientation='horizontal' then
     begin
      _x:= _x + _xmouse -xmouse;
      if _x<tr.w/15 then _x:=tr.w/15;
      if _x>tr.w-tr.w/15 then _x:=tr.w-tr.w/15;
      tr.position:=arrondi((_x-tr.w/15)*(trackmax-trackmin)/(tr.w-2*tr.w/15)+trackmin);
     end
     else if orientation='vertical' then  //non réalisé
     begin
      _y:= _y +_ymouse -ymouse;
     end;
     tr.onChange;
 end;
end;
 
 
 
procedure  TTrackcur.onMouseUp;
begin
 downcur:=false;
end;
 
procedure TTrackcur.onRollOver;
begin
 autorisation:=true;
end;
 
procedure TTrackcur.onRollOut;
begin
 autorisation:=false;
end;
 
constructor TTrackcur.create(AOWNER:Movieclip;trmin,trmax:integer);
 var matrix: Flash8.Matrix;
begin
  inherited Create(AOWNER,'cur',AOWNER.getNextHighestDepth);
  autorisation:=false;
  downcur:=false;
  xmouse:=0;
  ymouse:=0;
  matrix := Flash8.Matrix.Create();
  matrix.createGradientBox(4,4,0,-1,0);
  beginGradientFill('linear', [$f5f5f5,$f0f0f0,$c0c0c0], [100, 100,100], [0,2,210], matrix);
  linestyle(0.75,clblack);
  moveto(-2,-2);
  lineto(2,-2);
  lineto(2,0);
  lineto(0,4);
  lineto(-2,0);
  lineto(-2,-2);
  downcur:=false;
  xmouse:=0;
  ymouse:=0;
  trackmin:=trmin;
  trackmax:=trmax;
  Mouse.addListener(self);
end;
 
procedure TTrackcur.onMouseWheel(delta: Number; scrollTarget: TObject);
var posi:number;
    tr:TTrackbar;
begin
 tr:=TTrackbar(_parent);
 posi:=tr.position;
 if delta >0 then delta := 1 else delta := -1;
 tr.position:=tr.position+delta;
 if  (tr.position>=trackmin) and (tr.position<=trackmax) {and autorisation} then
 begin
  _x:=tr.w/15+abs(tr.position-trackmin)*(tr.w-2*tr.w/15)/(trackmax-trackmin);
  tr.onChange;
 end else  tr.position:=posi;
end;
 
Procedure TTrackcur.dessin;
begin
 
end;
 
end.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
program Project1;
 
{$FRAME_WIDTH 550}
{$FRAME_HEIGHT 400}
{$FRAME_RATE 12}
{$BACKGROUND $FFFFFF}
 
uses
  Flash8,utrack;
 
var track,track2:TTrackbar;
 
begin
  track:=TTrackbar.Create(_root);
  with track do
  begin
   left:=20;
   top:=70;
   width:=300;
   position:=0;
   color:=$00ff00;
   cur.orientation:='horizontal';
   cur.trackmin:=0;
   cur.trackmax:=30;
   graduation;
  end;
 
  track2:=TTrackbar.Create(_root);
  with track2 do
  begin
   left:=20;
   top:=150;
   width:=300;
   position:=0;
   color:=$ff0000;
   cur.orientation:='horizontal';
   cur.trackmin:=0;
   cur.trackmax:=10;
   graduation;
  end;
end.
Je n'ai pas trop le temps de travailler dessus, ce n'est qu'un début pour l'instant...J'ai surtout travaillé le look.