Announcement

Collapse
No announcement yet.

Shortcuts und TAction

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shortcuts und TAction

    Hallo erstmal,

    ich habe folgendes Problem. In meinem Hauptformular habe ich eine TActionMainMenueBar, die mit einem Actionmanager verknüpft ist. Nun möchte ich zur Laufzeit Einträge im Menü erzeugen, die mit einem Shortcut belegt werden.
    So weit so gut, es funktioniert auch alles... außer den Shortcuts. Sie werden zwar angezeigt, aber das Programm reagiert nicht darauf.

    Was mache ich falsch?<BR><BR>

    procedure TForm1.FormCreate(Sender: TObject);<BR>
    &nbsp;&nbsp; begin<BR>
    &nbsp;&nbsp;&nbsp;FTastenInt := 1;<BR>
    &nbsp;end;<BR>

    procedure TForm1.BitBtn1Click(Sender: TObject);<BR>
    &nbsp;&nbsp;Var<BR>
    &nbsp;&nbsp;&nbsp;MyAction : TAction;<BR>
    &nbsp;&nbsp;&nbsp;i1 : Integer;<BR><BR>

    &nbsp;&nbsp;Begin<BR>
    &nbsp;&nbsp;&nbsp;MyAction := TAction.Create(Form1);<BR><BR>

    &nbsp;&nbsp;&nbsp;MyAction.Caption := IntToStr(FTastenInt);<BR>
    &nbsp;&nbsp;&nbsp;MyAction.OnExecute := Action2Execute;<BR><BR>

    &nbsp;&nbsp;&nbsp;If (FTastenInt >= 1) And (FTastenInt <= 12) Then<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Begin<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyAction.Short Cut := TextToShortCut('F'+IntToStr(FTastenInt));<BR>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End;<BR><BR>

    &nbsp;&nbsp;&nbsp;Inc(FTastenInt);<BR>

    &nbsp;&nbsp;&nbsp;Form1.ActionManager1.AddAction(M yAction, Form1.ActionManager1.FindItemByCaption('&Test').It ems[0])<BR>
    End;<BR><BR>

    procedure TForm1.Action2Execute(Sender: TObject);<BR>
    &nbsp;&nbsp;begin<BR>
    &nbsp;&nbsp;&nbsp;ShowMessage('Eine F-Taste wurde wurde gedrückt.'); <BR>
    &nbsp;&nbsp;end;<BR><BR>

    Ich habe schon alles mögliche versucht, auch anstelle von TextToShortCut() ShortCut() zu verwenden.
    Ich bin für jede Hilfe dankbar,

    Viele Grüsse,

    Herbert
Working...
X