KeyPress Problem
Hallo
der Panel bewegt immer mit 10 Pixel ! egal ob ich die taste Pfeil allein oder CTRL+Pfeil Taste
Delphi-Quellcode:
Woran liegt es dann ?
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); begin if ((Key = 17) and (Key = 39)) then begin Panel1.left:= Panel1.left+1; end; if Key = 39 then begin Panel1.left:= Panel1.left+10; end; end; |
Re: KeyPress Problem
Zitat:
Wenn du den Status der Tasten Shift, Strg usw. auslesen möchtest, dann schau dir doch einmal den Wert des Parameters Shift an. ;-) |
Re: KeyPress Problem
Delphi-Quellcode:
Vielleicht hilft das?
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); begin if ((Key = 17) and (Key = 39)) then begin Panel1.left:= Panel1.left+1; end; if ((Key <> 17) and Key = 39)) then begin Panel1.left:= Panel1.left+10; end; end; Gerd |
Re: KeyPress Problem
Zitat:
Wie soll das gehen? Ich habe das doch schon geschrieben... :roll: Vielleicht anders... Das ist wie wenn du im Laden sagst: Wenn diese Frucht eine Banane ist UND diese Frucht eine Ananas ist, dann nehme ich sie. Kann die selbe Frucht jemals eine Banane UND eine Ananas gleichzeitig sein? Nein. Genauso wenig kann Key gleichzeitig 17 UND 39 sein... Die richtige Lösung ist die Abfrage des Parameters Shift. |
Re: KeyPress Problem
Es müsste wohl eher so aussehen:
Delphi-Quellcode:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); begin if (ssCtrl in Shift) and (Key = 39) then Panel1.left := Panel1.left + 1; end else if Key = 39 then Panel1.left:= Panel1.left+10; end; |
Re: KeyPress Problem
Wichtig ist das else, da die 2. Bedingung in beiden Fällen erfüllt ist und ausgeführt werden würde.
|
Re: KeyPress Problem
@HighSpeed: Da war dann doch ein end zuviel...
Etwas anders formuliert funktioniert es auch:
Delphi-Quellcode:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin if Key = 39 then begin if ssCtrl in Shift then Panel1.left := Panel1.left + 1 else Panel1.left := Panel1.left + 10; Key := 0; // optional, damit kein anderes Control mehr auf den Key reagieren kann end; end; |
Re: KeyPress Problem
es ging nun
Ich habe allerdings ein ganz neues Projekt erstellt. Danke |
Re: KeyPress Problem
@ Uwe Raabe:
stimmt, is beim begin / end löschen wohl irgendwie übrig geblieben... aber das passiert ja schonmal, wenn man nich alles immer duch n compiler laufen lässt |
Re: KeyPress Problem
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:06 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz