IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flash Pascal Discussion :

Edit et onKeyDown [Flash Pascal]


Sujet :

Flash Pascal

  1. #1
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut Edit et onKeyDown
    Hello, j'ai essayé d'implanter un Edit en attendant...
    Il faut d'ailleurs que je reprenne mes propriétés en lecture...

    Mon souci est que lorsque je rentre une chaîne de caractères dans l'édit, le résultat dans le label est que j'ai toujours un caractère de retard...
    Comme si le onKeyDown se faisait avant l'affectation de edit.text...

    ci-joint :

    UFont est dans le post précédent... je ne l'ajoute pas...

    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
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
     
    unit UFlash8CL;
     
    interface
     
    uses Flash8,UFont;
     
    const
      distance=1;
      angleInDegrees=45;
      coul1=$808080;
      highlightAlpha=0.8;
      coul2=$646464;
      shadowAlpha=0.9;
      blurX=5;
      blurY=5;
      strength=5;
      quality=3;
      typ='inner';
     
    type
     TLabel=Class
      Private
       FBorder,FwordWrap,Fautosize,FBackground,FBackgroundcolor,Fmultiline,first:Boolean;
       FLeft,FTop,FWidth,FHeight,FBordercolor,Frotation:number;
       FCaption:string;
       FTextfield:TextField;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetBorder(value:boolean);
       procedure SetborderColor(value: Number);
       procedure SetwordWrap(value:boolean);
       procedure SetAutosize(value:boolean);
       procedure SetBackground(value:Boolean);
       procedure SetBackgroundColor(value:number);
       procedure Setmultiline(value: Boolean);
       procedure Setrotation(value: Number);
       procedure SetCaption(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       property Left:number read FLeft write SetLeft;
       property Top:number read FTop write SetTop;
       property width:number read FWidth write SetWidth;
       property height:number read FHeight write SetHeight;
       property Border:Boolean read FBorder write SetBorder;
       property BorderColor:number read FBordercolor write SetBordercolor;
       property wordWrap:boolean read FwordWrap write SetwordWrap;
       property autosize:boolean read Fautosize write Setautosize;
       property Background:boolean read FBackground write SetBackground;
       property Backgroundcolor:number read FBackgroundcolor write SetBackgroundcolor;
       property multiline:boolean read Fmultiline write Setmultiline;
       property rotation:number read Frotation write Setrotation;
       property caption:string read FCaption write setCaption;
    end;
     
    {*********
    **Edit****
    **********
     
     TEdit=class(TLabel)
      private
       FText:String;
       procedure SetText(value:string);
       procedure onKeyDown;
      public
       constructor Create(parent:movieclip);
       procedure onChange;virtual;
       property text:string read Ftext write settext;
     end;}
     
     TEdit=Class
      Private
       FBorder,FwordWrap,Fautosize,FBackground,FBackgroundcolor,Fmultiline,first:Boolean;
       FLeft,FTop,FWidth,FHeight,FBordercolor,Frotation:number;
       FTextfield:TextField;
       Function getText:string;
       procedure onKeyDown;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetBorder(value:boolean);
       procedure SetborderColor(value: Number);
       procedure SetwordWrap(value:boolean);
       procedure SetAutosize(value:boolean);
       procedure SetBackground(value:Boolean);
       procedure SetBackgroundColor(value:number);
       procedure Setmultiline(value: Boolean);
       procedure Setrotation(value: Number);
       procedure SetText(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       procedure onChange;virtual;
       property Left:number read FLeft write SetLeft;
       property Top:number read FTop write SetTop;
       property width:number read FWidth write SetWidth;
       property height:number read FHeight write SetHeight;
       property Border:Boolean read FBorder write SetBorder;
       property BorderColor:number read FBordercolor write SetBordercolor;
       property wordWrap:boolean read FwordWrap write SetwordWrap;
       property autosize:boolean read Fautosize write Setautosize;
       property Background:boolean read FBackground write SetBackground;
       property Backgroundcolor:number read FBackgroundcolor write SetBackgroundcolor;
       property multiline:boolean read Fmultiline write Setmultiline;
       property rotation:number read Frotation write Setrotation;
       property text:string read getText write setText;
    end;
     
     
     
     
    {*********
    **Button**
    **********}
     
     
     TButton=class(movieclip)
     
     private
      click,First:Boolean;
      FLeft,FTop,FWidth,FHeight:number;
      skin1,skin2:movieclip;
      w,h:number;
      title: TextField;
      bevel1,bevel2:BevelFilter;
      myfilterArray:TArray;
      procedure skin;
      procedure SetCaption(value:string);
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
      procedure onPress;override;
      procedure onMouseUp;override;
     public
      Font:Tfont;
      procedure onClick;virtual;
      constructor create(parent:movieclip);
      property Caption:string read title write SetCaption;
      property Left:number read FLeft write SetLeft;
      property Top:number read FTop write SetTop;
      property width:number read FWidth write SetWidth;
      property height:number read FHeight write SetHeight;
     end;
     
     
    implementation
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     FTextfield:=TextField.Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     first:=true;
    end;
     
    procedure TLabel.Setleft(value:number);
    begin
       FTextfield._x:=value;
    end;
     
    procedure TLabel.SetTop(value:number);
    begin
       FTextfield._y:=value;
    end;
     
    procedure TLabel.SetWidth(value:number);
    begin
       FTextfield._width:=value;
    end;
     
    procedure TLabel.SetHeight(value:number);
    begin
       FTextfield._height:=value;
    end;
     
    procedure TLabel.SetBorder(value:boolean);
    begin
       FTextfield.border:=value;
    end;
     
    procedure TLabel.SetBordercolor(value:number);
    begin
       FTextfield.bordercolor:=value;
    end;
     
    procedure TLabel.SetwordWrap(value:Boolean);
    begin
     FTextfield.wordWrap:=value;
    end;
     
    procedure TLabel.Setautosize(value:boolean);
    begin
     if value then FTextfield.autosize:='center';
    end;
     
    procedure TLabel.SetBackground(value:Boolean);
    begin
     FTextfield.background:=value;
    end;
     
    procedure TLabel.SetBackgroundcolor(value:number);
    begin
     FTextfield.backgroundcolor:=value;
    end;
     
    procedure TLabel.Setmultiline(value:Boolean);
    begin
     FTextfield.multiline:=value;
    end;
     
    procedure TLabel.Setrotation(value:number);
    begin
     FTextfield._rotation:=value;
    end;
     
     
    procedure TLabel.SetCaption(value:string);
    begin
     if first then
     begin
      FTextfield.setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     FTextfield.text:=value;
    end;
     
    {*********
    **Edit****
    **********
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     inherited Create(parent);
     FTextfield.type:='input';
     Key.Addlistener(self);
    end;
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      FTextfield.setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     FTextfield.text:=value;
    end;
     
    procedure TEdit.onKeyDown;
    begin
     onChange;
    end;
     
    Procedure TEdit.onChange;
    begin
    end; }
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     FTextfield:=TextField.Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     FTextfield.type:='input';
     first:=true;
     Key.Addlistener(self);
    end;
     
    procedure TEdit.Setleft(value:number);
    begin
       FTextfield._x:=value;
    end;
     
    procedure TEdit.SetTop(value:number);
    begin
       FTextfield._y:=value;
    end;
     
    procedure TEdit.SetWidth(value:number);
    begin
       FTextfield._width:=value;
    end;
     
    procedure TEdit.SetHeight(value:number);
    begin
       FTextfield._height:=value;
    end;
     
    procedure TEdit.SetBorder(value:boolean);
    begin
       FTextfield.border:=value;
    end;
     
    procedure TEdit.SetBordercolor(value:number);
    begin
     FTextfield.bordercolor:=value;
    end;
     
    procedure TEdit.SetwordWrap(value:Boolean);
    begin
     FTextfield.wordWrap:=value;
    end;
     
    procedure TEdit.Setautosize(value:boolean);
    begin
     if value then FTextfield.autosize:='center';
    end;
     
    procedure TEdit.SetBackground(value:Boolean);
    begin
     FTextfield.background:=value;
    end;
     
    procedure TEdit.SetBackgroundcolor(value:number);
    begin
     FTextfield.backgroundcolor:=value;
    end;
     
    procedure TEdit.Setmultiline(value:Boolean);
    begin
     FTextfield.multiline:=value;
    end;
     
    procedure TEdit.Setrotation(value:number);
    begin
     FTextfield._rotation:=value;
    end;
     
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      FTextfield.setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     FTextfield.text:=value;
    end;
     
    Function TEdit.getText:string;
    begin
     result:= FTextfield.text;
    end;
     
     
    procedure TEdit.onKeyDown;
    begin
      onChange;
    end;
     
    Procedure TEdit.onChange;
    begin
    end;
     
     
    {*********
    **Button**
    **********}
     
    constructor TButton.Create(parent:movieclip);
    begin
     inherited Create(parent,'button',movieclip(parent).getNextHighestDepth());
     w:=90;
     h:=30;
     left:=10;
     top:=10;
     myfilterArray:=TArray.Create();
     
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
      align:='center';
     end;
     
     skin1:=movieclip.create(self,'',1);
     skin2:=movieclip.create(self,'',2);
     
     with skin1 do
     begin
      bevel1:=BevelFilter.create(distance,angleInDegrees,coul1,highlightAlpha,coul2,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel1);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     with skin2 do
     begin
      bevel2:=BevelFilter.create(distance,angleInDegrees,coul2,highlightAlpha,coul1,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel2);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     First:=true;
     click:=false;
     skin;
     
     Title:=TextField.Create(self,'',getNextHighestDepth(),0,0,w,h);    //TLabel  ça bugue
     with Font do
     begin
      name:='arial';
      size:=20;
     end;
    end;
     
    procedure TButton.skin;
    begin
     if not click then
     begin
      skin1._visible:=true;
      skin2._visible:=false;
     end else
     begin
      skin1._visible:=false;
      skin2._visible:=true;
     end;
    end;
     
    procedure TButton.SetCaption(Value: string);
    begin
     with title do
     begin
      if first then
      begin
       setNewTextFormat(Font.FTextFormat);
       first:=false;
      end;
      text:=value;
     end;
    end;
     
     
    procedure TButton.onClick;
    begin
    end;
     
    procedure TButton.onPress;
    begin
     click:=true;
     skin;
     onClick;
    end;
     
    procedure TButton.onMouseUp;
    begin
     click:=false;
     skin;
    end;
     
    procedure TButton.Setleft(value:number);
    begin
     _x:=value;
    end;
     
    procedure TButton.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TButton.SetWidth(value:number);
    begin
       _xscale:=100*value/w;
       _yscale:=_xscale;
    end;
     
    procedure TButton.SetHeight(value:number);
    begin
      _yscale:=100*value/h;
    end;
     
    end.
    et :
    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
     
    program Project1;
     
    {$FRAME_WIDTH 550}
    {$FRAME_HEIGHT 400}
    {$FRAME_RATE 12}
    {$BACKGROUND $FFFFFF}
     
     
     
    uses
      Flash8,UFlash8CL;
     
    Type
     
     TButton1=class(TButton)
      procedure onClick;override;
     end;
     
     TButton2=class(TButton)
      procedure onClick;override;
     end;
     
     TEdit1=class(TEdit)
      procedure onChange;override;
     end;
     
     
    var
     Button1: TButton1;
     Button2: TButton2;
     Label:TLabel;
     Edit1:TEdit1;
     
    procedure TButton1.onClick;
    begin
     label.caption:='Button1';
    end;
     
    procedure TEdit1.onChange;
    begin
     label.caption:=text;
    end;
     
    procedure TButton2.onClick;
    begin
     label.caption:='Button2';
    end;
     
    begin
     
     Label:=TLabel.Create(_root);
     with Label do
     begin
      with Font do
      begin
       name:='arial';
       size:=40;
       color:=clred;
      end;
      caption:="J'attends la modification";
      left:=15;
      top:=150;
      width:=500;
     end;
     
     Edit1:=TEdit1.Create(_root);
     with Edit1 do
     begin
      border:=true;
      with Font do
      begin
       name:='arial';
       size:=40;
      end;
      left:=250;
      top:=10;
      width:=200;
      height:=50;
      text:='';
     end;
     
     Button1:=TButton1.create(_root);
     with Button1 do
     begin
      caption:='Button1';
      left:=15;
      top:=10;
      width:=120;
     end;
     
     Button2:=TButton2.create(_root);
     with Button2 do
     begin
      caption:='Button2';
      left:=15;
      top:=65;
      width:=120;
     end;
     
     
    end.
    Pour l'instant, je n'ai pas éclairci le mystère

  2. #2
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    oui c'est normal, tu peux utiliser onKeyup ou TextField.onChanged
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  3. #3
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    oui c'est normal, tu peux utiliser onKeyup ou TextField.onChanged
    Parfait

    Nickel !

    merci

  4. #4
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Finalement, j'ai opté pour le onChanged... c'est plus propre...
    Mais j'ai été obligé de faire dériver TLabel et TEdit de TextField car mes tentatives pour lier le onChanged de FTextField avec le onChange de l'edit ont été vaines...

    D'un autre coté, je n'ai plus besoin de redéfinir toutes les propriétés de TextField déjà existantes...

    Le seul souci étant la propriété Text que je redéfinis...donc là, à part le fait de la renommer (ici texte au lieu de text ) je n'ai pas vu d'autres solutions.

    ci-joint :

    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
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
     
    unit UFlash8CL;
     
    interface
     
    uses Flash8,UFont;
     
    const
      distance=1;
      angleInDegrees=45;
      coul1=$808080;
      highlightAlpha=0.8;
      coul2=$646464;
      shadowAlpha=0.9;
      blurX=5;
      blurY=5;
      strength=5;
      quality=3;
      typ='inner';
     
    type
     TLabel=Class(TextField)
      Private
       first:Boolean;
       FLeft,FTop,FWidth,FHeight:number;
       Function  GetCaption:string;
       Function getLeft:number;
       Function getTop:number;
       Function getwidth:number;
       Function getHeight:number;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetCaption(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       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 caption:string read getCaption write setCaption;
    end;
     
    {*********
    **Edit****
    **********}
     
     TEdit=Class(TextField)
      Private
       first:Boolean;
       Function getText:string;
       Function getLeft:number;
       Function getTop:number;
       Function getwidth:number;
       Function getHeight:number;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetText(value:string);
       procedure onChanged(Ed:TEdit);override;
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       procedure onChange(Ed:TEdit);virtual;
       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 texte:string read getText write setText;
    end;
     
     
    {*********
    **Button**
    **********}
     
     
     TButton=class(movieclip)
     
     private
      click,First:Boolean;
      skin1,skin2:movieclip;
      w,h:number;
      bevel1,bevel2:BevelFilter;
      myfilterArray:TArray;
      Title:TextField;
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      Function getCaption:String;
      procedure skin;
      procedure SetCaption(value:string);
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
      procedure onPress;override;
      procedure onMouseUp;override;
     public
      Font:Tfont;
      procedure onClick;virtual;
      constructor create(parent:movieclip);
      property Caption:string read GetCaption write SetCaption;
      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;
     end;
     
    implementation
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     first:=true;
    end;
     
    procedure TLabel.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TLabel.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TLabel.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TLabel.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TLabel.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TLabel.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TLabel.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TLabel.GetHeight:number;
    begin
     result:=_height;
    end;
     
     
    procedure TLabel.SetCaption(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TLabel.GetCaption:string;
    begin
     result:=text;
    end;
     
    {*********
    **Edit****
    **********}
     
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     type:='input';
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     
     first:=true;
    end;
     
    Procedure TEdit.onChanged(Ed:TEdit);
    begin
     onchange(Ed);
    end;
     
    procedure TEdit.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TEdit.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TEdit.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TEdit.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TEdit.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TEdit.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TEdit.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TEdit.GetHeight:number;
    begin
     result:=_height;
    end;
     
     
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TEdit.getText:string;
    begin
     result:= text;
    end;
     
     
     
    Procedure TEdit.onChange(Ed:TEdit);
    begin
    end;
     
     
    {*********
    **Button**
    **********}
     
    constructor TButton.Create(parent:movieclip);
    begin
     inherited Create(parent,'button',movieclip(parent).getNextHighestDepth());
     w:=90;
     h:=30;
     left:=10;
     top:=10;
     myfilterArray:=TArray.Create();
     
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
      align:='center';
     end;
     
     skin1:=movieclip.create(self,'',1);
     skin2:=movieclip.create(self,'',2);
     
     with skin1 do
     begin
      bevel1:=BevelFilter.create(distance,angleInDegrees,coul1,highlightAlpha,coul2,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel1);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     with skin2 do
     begin
      bevel2:=BevelFilter.create(distance,angleInDegrees,coul2,highlightAlpha,coul1,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel2);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     First:=true;
     click:=false;
     skin;
     
     Title:=TextField.Create(self,'',getNextHighestDepth(),0,0,w,h);
     with Font do
     begin
      name:='arial';
      size:=20;
     end;
    end;
     
    procedure TButton.skin;
    begin
     if not click then
     begin
      skin1._visible:=true;
      skin2._visible:=false;
     end else
     begin
      skin1._visible:=false;
      skin2._visible:=true;
     end;
    end;
     
    procedure TButton.SetCaption(Value: string);
    begin
     with title do
     begin
      if first then
      begin
       setNewTextFormat(Font.FTextFormat);
       first:=false;
      end;
      text:=value;
     end;
    end;
     
    Function TButton.GetCaption:string;
    begin
     result:=title.text;
    end;
     
     
    procedure TButton.onClick;
    begin
    end;
     
    procedure TButton.onPress;
    begin
     click:=true;
     skin;
     onClick;
    end;
     
    procedure TButton.onMouseUp;
    begin
     click:=false;
     skin;
    end;
     
    procedure TButton.Setleft(value:number);
    begin
     _x:=value;
    end;
     
    procedure TButton.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TButton.SetWidth(value:number);
    begin
       _xscale:=100*value/w;
       _yscale:=_xscale;
    end;
     
    procedure TButton.SetHeight(value:number);
    begin
      _yscale:=100*value/h;
    end;
     
    Function TButton.GetLeft:number;
    begin
     result:=_x;
    end;
     
    Function TButton.GetTop:number;
    begin
     result:=_y;
    end;
     
    Function TButton.GetWidth:number;
    begin
     result:=_width;
    end;
     
    Function TButton.GetHeight:number;
    begin
     result:=_height;
    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
    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
     
    program Project1;
     
    {$FRAME_WIDTH 550}
    {$FRAME_HEIGHT 400}
    {$FRAME_RATE 12}
    {$BACKGROUND $FFFFFF}
     
     
     
    uses
      Flash8,UFlash8CL;
     
    Type
     
     TButton1=class(TButton)
      procedure onClick;override;
     end;
     
     TButton2=class(TButton)
      procedure onClick;override;
     end;
     
     TEdit1=class(TEdit)
      procedure onChange(Ed:TEdit);override;
     end;
     
     
    var
     Button1: TButton1;
     Button2: TButton2;
     Label:TLabel;
     Edit1:TEdit1;
     
    procedure TButton1.onClick;
    begin
     label.caption:='Button1';
    end;
     
    procedure TEdit1.onChange(Ed:TEdit);
    begin
     label.caption:=Ed.texte;
    end;
     
    procedure TButton2.onClick;
    begin
     label.caption:='Button2';
    end;
     
    begin
     
     Label:=TLabel.Create(_root);
     with Label do
     begin
      with Font do
      begin
       name:='arial';
       size:=40;
       color:=clred;
      end;
      caption:="J'attends la modification";
      left:=15;
      top:=150;
      width:=500;
     end;
     
     Edit1:=TEdit1.Create(_root);
     with Edit1 do
     begin
      border:=true;
      with Font do
      begin
       name:='arial';
       size:=40;
      end;
      left:=250;
      top:=5;
      width:=200;
      height:=50;
      texte:='';
     end;
     
     Button1:=TButton1.create(_root);
     with Button1 do
     begin
      caption:='Button1';
      left:=15;
      top:=10;
      width:=120;
     end;
     
     Button2:=TButton2.create(_root);
     with Button2 do
     begin
      caption:='Button2';
      left:=15;
      top:=65;
      width:=120;
     end;
     
    end.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 23/10/2002, 13h38
  2. [Kylix] Télécharger Kylix 3 Open Edition
    Par RDM dans le forum EDI
    Réponses: 2
    Dernier message: 27/08/2002, 11h28
  3. Hint et edit.enbled
    Par Invité dans le forum Composants VCL
    Réponses: 2
    Dernier message: 23/07/2002, 09h26
  4. Position du curseur dans Edit
    Par MrJéjé dans le forum C++Builder
    Réponses: 3
    Dernier message: 20/06/2002, 17h09
  5. Image et rich edit
    Par :GREG: dans le forum C++Builder
    Réponses: 2
    Dernier message: 13/05/2002, 11h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo