Autor Beitrag
ptronick
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

win xp prof.
D5 Stand
BeitragVerfasst: So 25.04.04 17:23 
Hi,
ich benutze in meinem Programm ein Edit-Eingabefeld.
Ich will eine Zahl hineinschreiben und dann mit Enter oder Return bestätigen.
Ich mach jetzt schon ewig am Objektinspektor rum, aber die "OnEnter"-Spalte
will nicht funktionieren. Das Programm ignoriert es einfach (glaub ich).

Hier mein Quelltext:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.edit1Enter(Sender: TObject);
begin
eigene:=edit1.text;                   { Einlesen der Variable "eigene"  } 
val(eigene,eigenem,code);        { Umwandeln in Integer }
erg:=erg-eigenem;                   { Arbeiten mit der neu gewonnen Zahl }
ANZEIGE;                                { Prozedur, die auf die Variable "erg" sehnsüchtig wartet }
end;


Wenn ich den Quelltext in nen Button schreib funktioniert es einwandfrei.
Danke fürs Lesen

Patrick

Moderiert von user profile iconPeter Lustig (17:24, 25.04.2004): Delphi-Tags hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 25.04.04 17:28 
Hallo!

Bei einem TEdit (T-Edit) :mrgreen:) wird das OnEnter-Ereignis nicht bei der Taste "Enter" ausgelöst, sondern wenn der Cursor im Edit-Feld platziert wird. Um auf die Entertaste zu reagieren, empfielt sich das OnKeyPress-Ereignis.

In diesem Ereignis prüfst Du:
ausblenden Delphi-Quelltext
1:
if Ord(key) = vk_return then					


Ist dies wahr, führst Du Deinen Code aus.

Mfg
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
ptronick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

win xp prof.
D5 Stand
BeitragVerfasst: So 25.04.04 17:31 
danke für die schnelle Antwort. Der Vorschlag klingt vielversprechend.
Aber wo soll ich ihn hineinschreiben?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 25.04.04 17:32 
Wie gesagt: Ins OnKeyPress-Ereignis des Edit-Feldes. Sollte im OI zu finden sein. Dort einfach die oben stehende Abfrage einfügen und in die Zweig, der bei true ausgeführt wird, Deinen Code.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
ptronick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

win xp prof.
D5 Stand
BeitragVerfasst: So 25.04.04 17:38 
Titel: juhuu
es klappt!!!!!
Vielen Dank!!!
Jetzt bist du mein persöhnlicher Held des Tages!!!!
mstuebner
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 132

Win2000, XP
D7
BeitragVerfasst: So 25.04.04 17:46 
ptronick hat folgendes geschrieben:
Das Programm ignoriert es einfach (glaub ich).

Um das "Glaub ich" auszuschliessen kann man in Funktionen/Proceduren zu diesem Zwecke einen Breakpoint setzen. Stoppt Dein Programm dann an dieser Stelle nicht, dann wird der Code "Sicher" nicht ausgeführt.

_________________
mfg Matthias
ptronick Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 22

win xp prof.
D5 Stand
BeitragVerfasst: So 25.04.04 18:22 
danke!
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 17.07.04 21:06 
Hi
Danke es klappt.
Nur kommt immer das nervige "plong" (Fehlermeldung) wenn ich Enter drücke. Wenn ich den Button der mit Enter aufgerufen wird normal drücke kommt es nicht. Kann es daran liegen das ich nicht in ein Edit sonder in eine ComboBox schreibe?
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Sa 17.07.04 21:14 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if Ord(key) = vk_return then
  begin
    key:=#0;
    ...
  end;

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 17.07.04 21:25 
Delphi hat folgendes geschrieben:

Inkompatible Typen: 'Word' und 'Char'
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 17.07.04 21:26 
Kleine Anmerkung: Der folgende Code macht genau das gleiche:

ausblenden Delphi-Quelltext
1:
If Key = #13 Then DoSomething;					

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 17.07.04 21:30 
Sorry, Sorry, war mein Fehler. Ich habe es nicht bei OnKeyPress sonder bei OnKeyDown hingeschrieben. :autsch: