Autor Beitrag
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 05.12.04 20:20 
Hallo,
wie der Titel vielleicht schom impliziert, habe ich ein Problem. Ich habe hier den Code einer nachgebauten Konsole.
Funktioniert alles Wunderbar. Jetzt wollte ich eine History einbauen...

ConsoleCounter ist Integer und ConsoleHistory eine StringList

das sollte auch soweit gehen, wie ich mir das gedacht habe, aber weder bei Bildhoch oder Bildrunter, noch bei den Pfeiltasten nach oben oder unten wird das Ereignis ausgeloest, was ich hier zu behandeln versuche.

InputEdt ist ein ganz normales Edit. Gibt eine eine moeglichkeit hier doch noch eine Code-History einzubauen?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
procedure TForm1.InputEdtKeyPress(Sender: TObject; var Key: Char);
var
  Input: string;
begin
  if Key = #13 then
  begin
    Console.Output('> ' + InputEdt.Text);
    Input := InputEdt.Text;
    InputEdt.Text := '';
    DoAction(Input);
    ConsoleHistory.Add(Input);
    If ConsoleHistory.Count > 20 then
      ConsoleHistory.Delete(0);
    ConsoleCounter := 19;
  end;

  if Key = #38 then  //Arrow Up
    if ConsoleCounter - 1 >= 0 then
    begin
      Dec(ConsoleCounter);
      InputEdt.Text := ConsoleHistory.Strings[ConsoleCounter];
    end;
    
  if Key = #40 then  //Arrow Down
    if ConsoleCounter + 1 < ConsoleHistory.Count then
    begin
      Inc(ConsoleCounter);
      InputEdt.Text := ConsoleHistory.Strings[ConsoleCounter];
    end;
end;



gruesse

Maweki
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: So 05.12.04 21:44 
Guck dir mal das OnKeyDown Event an. Damit kriegst jede Tastatureingabe nur leider nicht also Char.
Maweki Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: So 05.12.04 23:04 
Ja danke, das hat mir weitergeholfen. Das ging dann mit vk_up und vk_down

ein wenig muss ich an der Methode noch feilen, aber das Problem is geloest. Danke...
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: So 05.12.04 23:23 
kein Problem :D