Autor Beitrag
kuschelfreddy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Sa 14.03.09 16:59 
Hallo ihr alle!

Ich schon wieder....
Ich wollte nur kurz wissen, ob es in Delphi eine einfache Möglichkeit gibt, einen Button, ohne darauf zu klicken, zu benutzen!?!
Ich stelle mir das so vor: Ich habe ein Edit-Feld, in das ich etwas eintrage, einen Button und ein Memofeld. Beim Klick auf den Button wird der Inhalt des Editfeldes in das Memofeld überschrieben. Nun möchte ich stattdessen, nach eingeben des Inhaltes in das Editfeld, nur Enter drücken, der Button wird aktiviert und der Inhalt übertragen. Also soll alles in allem das doofe Geklicke umgangen werden. Ist sowas möglich? Und wenn ja, wie?

LG Nathalie
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 14.03.09 17:01 
Du prüfst im OnKeyUp des Editfeldes, ob Key=vk_Return. Dann noch auf die Button-Klick Prozedur linken und fertig :) .

Edit: Nochmal Quelltext:
ausblenden Delphi-Quelltext
1:
2:
  if Key=VK_RETURN then
    Button1Click(self);
kuschelfreddy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Sa 14.03.09 17:05 
Super, danke für die schnelle Antwort!
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 14.03.09 17:06 
Hallo

du hast 2 Möglichkeiten, entwede in einem Key-Ereignis die Enter-Taste prüfen
z.B. Keypress;
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
      memo2.lines.add(edit1.Text);
      key:=#0;
    end;
end;


oder: Du stellst die Eigenschaft "Default" des Buttons auf true, dann brauchst du kein Ereignis im Edit.

edit: Mist, zu langsame ;-)

Gruß Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)