Autor Beitrag
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Fr 21.03.14 18:10 
Hallo zusammen,

ich habe ein Problem mit TActionManager, ActionLists und Action Shortcuts.

In Application.Mainform liegt der Actionmanager und einige ActionLists. Die Shortcuts der dort enthaltenen Actions funktionieren, wie gewünscht.
Die Actions lassen sich über zugehörige Buttons aufrufen.


Das Problem kommt, wenn ich eines meiner Programm Module (Frames) lade und im Mainform auf einem Panel anzeigen lasse.

Ich lade die Aktionen des Frames und füge für jede Aktion einen neuen Button ins interface ein. Das Funktioniert und ich kann dann auch die Funktion des Frames aufrufen.

Allerdings habe ich dann den Shortcut noch nicht. Dazu hab ich mir überlegt, das ich die Frame.ActionList zum Actionmanager hinzufüge. Das klappt auch, jedoch werden die Shortcuts nicht erkannt und damit werden die Actions nicht über Tastaturkürzel ausgelöst.

Hat jemand ne idee, was da falsch läuft, oder was ich vergessen habe?

Nachfolgend der Quellcode.

ausblenden volle Höhe 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:
31:
32:
33:
  LToolbar := getNewToolBar();
  for LActnIdx := 0 to AFrame.IGetActionCount - 1 do begin
    LAction := AFrame.IGetActionByIndex(LActnIdx);

    if pos('Separator', LAction.Caption) = 0 then begin
      LTBtn := TAdvGlowButton.Create(LToolBar);
      LTBtn.Transparent := true;
      LTBtn.Action := LAction;
      LTBtn.Height := 56;
      LToolBar.AddToolBarControl(LTBtn);
    end
    else if LAction.Visible then begin
      LToolBar.EndUpdate;
      LToolBar := getNewToolBar();
    end;
  end;
  LToolBar.EndUpdate;

  // hier kommt der problematische teil, also die ShortCuts feuern nicht...
  with ActionManager1 do begin
    while LinkedActionLists.count > 4 do begin
      LAListItem := LinkedActionLists[LinkedActionLists.count -1];
      LAListItem.ActionList := nil;
      LinkedActionLists.Delete(LinkedActionLists.count -1);
    end;

    LAList := AFrame.IGetActionList;
    if LAList <> nil then
      with LinkedActionLists.Add as TActionListItem do begin
        Caption := LAList.Name;
        ActionList := LAList;
      end;
  end;



Gruß
CenBells

Moderiert von user profile iconMartok: Code- durch Delphi-Tags ersetzt

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
CenBells Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Sa 22.03.14 23:06 
Ich hab das Problem dann noch lösen können.

Und zwar habe ich eine weitere leere ActionList (ALActions) dem ActionManager zugeordnet (linkedActionList...).
In diese füge ich dann im Hauptformular lokal erzeugte Aktionen ein.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
...
  for LActnIdx := 0 to AFrame.IGetActionCount - 1 do begin
    LAction := AFrame.IGetActionByIndex(LActnIdx);
// die aktion mit einer Aktion des Hauptformulars verlinken, damit die Tastaturkürzel funktionieren...
    LMAinFormAction := TAction.Create(ALActions);
    LMainFormAction.Assign(LAction);
    LMainFormAction.ActionList := ALActions;
...


Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.