Autor Beitrag
Patrice
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Di 05.04.05 12:08 
Mahlzeit ^^
und zwar arbeite ich gerade an einem Projekt bei dem ein Kunde bei der "Kundenregestrierung" ein Passwort eingeben soll. Hierzu soll automatisch vom ersten in das 2te Editfeld gesprungen werden wenn er die erste Passworteingabe per Druck auf die Entertaste bestätigt. Hoffe das ich mein Problem einigermaßen erklären konnte ^^.
Gruss
Patrick
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Di 05.04.05 12:16 
Aus CodeCentral von Borland:

Code to make the <Enter>key act as the tab key while inside a grid.

This code also includes the processing of the <Enter> key for the entire
application - including fields, etc. The grid part is handled in the
ELSE portion of the code. The provided code does not mimic the behavior
of the <Tab> key stepping down to the next record when it reaches the last
column in the grid - it moves back to the first column - .
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);

{ This is the event handler for the FORM's OnKeyPress event! }
{ You should also set the Form's KeyPreview property to True }
begin
  if Key = #13 then                              { if it's an enter key }
    if not (ActiveControl is TDBGrid) then begin { if not on a TDBGrid }
      Key := #0;                                 { eat enter key }
      Perform(WM_NEXTDLGCTL, 0, 0);              { move to next control }
    end
    else if (ActiveControl is TDBGrid) then      { if it is a TDBGrid }

      with TDBGrid(ActiveControl) do
        if selectedindex < (fieldcount -1) then  { increment the field }
          selectedindex := selectedindex +1
        else
          selectedindex := 0;
end;
Stübi
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 331

Win XP, Win 2000, Win ME
D5 Ent, D7 Prof, D2005 PE, C#
BeitragVerfasst: Di 05.04.05 12:17 
Du musst einfach beim ersten Edit das OnEnter-Ereignis benutzen, in dem schreibst du dan so etwas:
ausblenden Delphi-Quelltext
1:
  Edit2.SetFocus;					

Das sollte funktionieren.

Gruss Stübi

//Edit OnEnter stimmt nicht, OnEnter bedeutet, dass wenn der Cursor ins Feld springt (Enter etwa = Eingang). Du musst überprüfen ob ein Enterdruck vorliegt und anschliessend ob der Cursor im ersten Edit stand und dann SetFocus benutzen. Aber wahrscheinlich gibt es noch bessere Varianten. (z.B.: wdbee seine?!)

_________________
Neun von zehn Stimmen in meinen Kopf sagen, dass ich nicht verrückt sei. Die zehnte summt die Tetrismelodie.
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Di 05.04.05 12:33 
Hallo,

versuchs mal damit,
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure xxxxx (Sender: TObject; var Key: Char);
 begin
  if key = '13 then Self.Perform(WM_NEXTDLGCTL, 0,0);
 end;

Diese dann über Ereignis KeyPress des EditFeldes einbinden, müsste klappen.

Mike

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
Patrice Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Mi 06.04.05 06:42 
Also thx schonmal aber das funktioniert alles noch nicht, egal wie ich es mache jedesmal wenn ich im ersten Editfeld Enter betätige springt er sozusagen auf den Ok Button und führt damit eine Funktion aus, was er aber eigentlich erst nach dem 2ten Edit feld machen sollte hab es auch schon mit

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TFPasswortabfrage.EPasswort1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then Key := #9;
end;


versucht. Kann mir sonst einer noch Tips geben.
Gruss
Patrick

Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Mi 06.04.05 06:52 
Hallo,

Du musst natürlich die Reihenfolge der Tabstops so festlegen, dass Dein gewünschtes Feld als nächstes angesprungen wird. Entschuldige, das hatte ich nicht extra geschrieben.

Mike
Patrice Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Mi 06.04.05 07:01 
xD na danke :( so dümmlich bin ich dann doch noch nicht ^^, das erste Editfeld hast Taborder 0, das 2te 1 und der Btn hat Taborder 2. Trotzdem springt er bei Enter auf den Btn und führt ihn dazu auch noch gleich aus. Verzweifelt guck.
bug0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62

Win2000, Xp, Vista
Delphi 2006, 2009
BeitragVerfasst: Mi 06.04.05 07:17 
Hallo,

wie wäre es denn mit einer Kombination aus den vorigen Antworten...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    Key := #0;      //Damit unterbindest du den lästige 'Bing'
    Edit2.SetFocus; //Wechsel zum 2. Eingabefeld
  end;
end;
Patrice Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Mi 06.04.05 07:22 
Das hatte ich gleich als erstes versucht ^^ komischer Weise klappt es sobald ich den Btn ausm Fenster raus nehme *augen verdreh*.
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Mi 06.04.05 07:48 
Hallo,

noch ein dümmlicher Hinweis,

hast Du auch in Form1 KeyPreview auf True gesetzt ?

Mike
Patrice Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Mi 06.04.05 08:10 
Ne hab steht auf False aber das hat doch auch nichts mit dem Edit KeyPress zutun soviel ich weiß weil soviel ich weiß hat KeyPreview nur die funktion das "falls" sie auf True gesetzt ist das Formular zuerst die Tastaturereignisse bekommt und nicht das Steuerelement. Ist doch so oder? Aber hat sich nun erledigt, lass das fenster nun erstmal ohne Button :p
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 06.04.05 08:19 
Hallo,

das müsste so gehen, unabhängig von Taborder und Button:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
    ActiveControl := Edit2;
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Cybo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 87

Win 95/98/xp/NT Suse Linux
D7 Ent
BeitragVerfasst: Di 18.10.05 20:45 
ich hüpfe hier einfach mal mit rein.

if length(Labelededit2.Text)=Labelededit2.maxlength then Labelededit3.setfocus;

Das habe ich die Tage gebraucht, also änder es doch um.

if Key = #13 then Labelededit3.setfocus z.b...

_________________
Ich öffnete, kompilierte und traute meinen Augen nicht.


Zuletzt bearbeitet von Cybo am Mi 19.10.05 13:40, insgesamt 2-mal bearbeitet
Grishnak
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 221

Windows XP Home
Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Di 18.10.05 21:16 
Hatte dein Button das "Default"-Property auf "true"? Dann wird bei [RETURN] nämlich die OnClick-Methode des Buttons aufgerufen

_________________
Mach' etwas idiotensicher und irgendjemand erfindet einen besseren Idioten!