![]() |
Re: Navigation mit Pfeiltasten
Hi,
auch nicht schlecht, Vielen Dank. Gruß DM007 |
Re: Navigation mit Pfeiltasten
Du kannst das natürlich auch noch beliebig erweitern...
z.B: 1 > 2 > 3 > 4 > 1 > ...
Delphi-Quellcode:
1 > 2 > 1 > ...
VK_RIGHT:
if ActiveControl = RzBmpButton1 then ActiveControl := RzBmpButton2 else if ActiveControl = RzBmpButton2 then ActiveControl := RzBmpButton3 else if ActiveControl = RzBmpButton3 then ActiveControl := RzBmpButton4 else if ActiveControl = RzBmpButton4 then ActiveControl := RzBmpButton1; und 3 > 4 > 3 > ...
Delphi-Quellcode:
VK_RIGHT:
if ActiveControl = RzBmpButton1 then ActiveControl := RzBmpButton2 else if ActiveControl = RzBmpButton2 then ActiveControl := RzBmpButton1 else if ActiveControl = RzBmpButton3 then ActiveControl := RzBmpButton4 else if ActiveControl = RzBmpButton4 then ActiveControl := RzBmpButton3; |
Re: Navigation mit Pfeiltasten
generisch, das wort heißt generisch!
Delphi-Quellcode:
;)
var ControlIndex: Integer; //global, am besten mit 0 initialisieren
procedure TForm1.KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var Controls: array of TControl; begin if not ((Key = VK_LEFT) or (Key = VK_RIGHT)) then Exit; //wir wollen ja nicht alles abwürgen //die zuweisung sollte man natürlich auch global machen Setlength(Controls,4); Controls[0] := Btn1; Controls[1] := Btn2; Controls[2] := Btn3; Controls[3] := Btn4; case Key of VK_RIGHT: Inc(ControlIndex); VK_LEFT: Dec(ControlIndex); end; if ControlIndex < low(Controls) then ControlIndex := high(Controls) else if ControlIndex > high(Controls) then ControlIndex := low(Controls); ActiveControl := Controls[ControlIndex]; end; [edit=SirThornberry]Quelltext auf Wunsch korrigiert - Mfg, SirThornberry[/edit] |
Re: Navigation mit Pfeiltasten
Hallo,
Zitat:
VK_LEFT und VK_UP wie VK_TAB + VK_SHIFT (rückwärts entsprechend TabOrder) VK_RIGTH und VK_DOWN wie VK_TAB Also, Deine Buttons:
Code:
der Button 4 hat den Focus, du drückst die Taste Rechts.
---------------------------
| Button1 | Button12 | | Taborder 0 | Taborder 1 | --------------------------- | Button3 | Button14 | | Taborder 2 | Taborder 3 | --------------------------- Wenn es keinen TabOrder höher als den von Button4 (TabOrder 3) gibt, wird der Focus zu dem Button mit TabOrder 0 gesetzt, eben Button1. Welches Element soll denn den Focus bekommen wenn Button 4 den Focus und Taste Rechts betätigt wird? Noch eine Anmerkung: Im OnKeyDown der Form wird von ActiveControl das Element angegeben das den Focus bekommen hat. @DGL-luke Die Variable ControlIndex muss dann aber auch bei allen Focus-Änderung durch z.B. Mausklicks, Tab ... neu gesetzt werden. |
Re: Navigation mit Pfeiltasten
Hallo DGL-luke,
bitte korrigiere Deinen Beitrag: Zitat:
Dieses Verfahren ist meiner Ansicht nach das beste, weil es beliebig viele - auch unterschiedliche - Controls verarbeiten kann. Jürgen |
Re: Navigation mit Pfeiltasten
@Lannes,Jürgen: right.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:35 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz