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



BeitragVerfasst: Mi 06.07.22 14:14 
Guten Tag, kann mir hier bitte jemand erklären wie ich es schaffe Keys doppelt triggern zu lassen? Beispiel: Pause mit Escape, wieder entpausieren mit Escape. Zur Zeit löse ich das mit Escape zur Pause und zum entpausieren mit Leertaste. Das geht natürlich besser, aber wie? Hab schon was probiert aber das ist noch falsch. Ideen?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
     
     if key = vk_esc then
     begin
          keycheck := 1;
     end;

     if (key = vk_esc) and (keycheck = 1then
     begin
          keycheck := 0;
     end;


Was er da jeweils tun sollte hab ich mal rausgelassen. Würde gerne wissen wie das reine doppeltabfragen funktioniert. LG
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6386
Erhaltene Danke: 146

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 06.07.22 14:17 
Ganz klassisch:
Zunächst keycheck als Boolean definieren und dann:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
     
     if key = vk_esc then
     begin
          keycheck := not keycheck;
     end;
Lernenochdazu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 06.07.22 14:27 
user profile iconjasocul hat folgendes geschrieben Zum zitierten Posting springen:
Ganz klassisch:
Zunächst keycheck als Boolean definieren und dann:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
     
     if key = vk_esc then
     begin
          keycheck := not keycheck;
     end;


Ich habs mal so umgesetzt, so funktioniert es nicht. Ich hatte auch bei beiden not keycheck, damit hat es auch nicht funktioniert. Aber ich verstehe sowieso nicht wieso not keycheck. Ich will ja dass er einen keycheck macht. Wenn das erste getriggert wird und alles pausiert wird muss der bool ja umgesetzt werden zum Gegenstück, damit man mit der gleichen Taste das ganze wieder beenden kann. Dann muss wieder umgesetzt werden, damit man theoretisch wieder pausieren kann. Oder verstehe ich das falsch? LG

Moderiert von user profile iconTh69: Delphi-Tags hinzugefügt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8535
Erhaltene Danke: 473

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 06.07.22 14:39 
Das würde ich so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
if key = vk_esc then 
begin
  if keycheck then
    MachWas
  else
    MachWasAnderes;
  keycheck := not keycheck;
end;

Oder habe ich dein Vorhaben falsch verstanden? :gruebel:

_________________
We are, we were and will not be.
Lernenochdazu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 06.07.22 14:51 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
if key = vk_esc then
     begin
     if keycheck then
     begin
     end else
     begin
     keycheck := not keycheck;
     end;
     end;

So pausiert er aber entpausiert nicht mehr.

Moderiert von user profile iconTh69: Vollzitat entfernt.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8535
Erhaltene Danke: 473

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 06.07.22 15:05 
Schau dir nochmal meine Verschachtelung an. ;-)

Die Zeile keycheck := not keycheck; wird bei mir immer ausgeführt, wenn ESC gedrückt wird. Ganz egal, wie der Status von keycheck gerade ist. Denn der soll ja immer wechseln, wenn du diese Taste drückst, oder?

_________________
We are, we were and will not be.
Lernenochdazu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 06.07.22 15:36 
Es war eine Geburt, aber es funktioniert! Kp wieso ich das nicht direkt hatte. Danke.

Moderiert von user profile iconTh69: Vollzitat entfernt.