AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

FireMonkey Sammelthread

Ein Thema von mquadrat · begonnen am 1. Sep 2011 · letzter Beitrag vom 27. Jul 2013
 
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.355 Beiträge
 
Delphi 11 Alexandria
 
#31

AW: FireMonkey Sammelthread

  Alt 4. Mai 2013, 15:36
Eigentlich müssten nur "focused handler" und "change focus" getauscht werden.
Dann könnte man Key auf 0 setzen wenn man vkTab selbst behandeln will.

Wenn das in XE4 noch nicht geändert ist werde ich mal einen QC-Eintrag schreiben.
Delphi-Quellcode:
procedure TCommonCustomForm.KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState);
var
  List: TInterfaceList;
  i, CurIdx: Integer;
  TabDirection : Integer;
  FocusObj: TFmxObject;
  Done: boolean;
  FocusPopup: TCustomPopupMenu;
  lIsDialog: boolean;
  NewFocus: IControl;
  procedure TraverseChildren(Container: TFmxObject);
  var I: integer;
  begin
    if (Container is TControl) and
       (not TControl(Container).Enabled) then Exit;
    for I := 0 to Container.ComponentCount - 1 do
      if (Container.Components[I] is TCustomActionList) and
         (TCustomActionList(Container.Components[I]).DialogKey(Key, Shift)) then
      begin
        Done := True;
        Exit;
      end;
    if (Container.ChildrenCount > 0) then
      for I := 0 to Container.ChildrenCount - 1 do
      begin
        TraverseChildren(Container.Children[I]);
        if Done then
          Exit;
      end;
  end;
  procedure OtherForms(IsMain: boolean);
  var I, J: integer;
      F: TCommonCustomForm;
  begin
    if Done then Exit;
    for I := 0 to Screen.FormCount - 1 do
    if (Screen.Forms[I] <> self) and
       (Screen.Forms[I].Visible) and
       (IsMain xor (Screen.Forms[I] <> Application.MainForm)) then
    begin
      F := Screen.Forms[I];
      for J := F.ChildrenCount - 1 downto 0 do
      begin
        if F.Children[J] is TMainMenu then
          TMainMenu(F.Children[J]).DialogKey(Key, Shift);
        if Key = 0 then
        begin
          Done := True;
          Exit;
        end;
      end;
      TraverseChildren(F);
      if Done then Exit;
    end;
  end;
begin
  { dialog key }
  FocusPopup := nil;
  lIsDialog := False;
  IsDialogKey(Key, KeyChar, Shift, lIsDialog);
  try
    if lIsDialog then
    begin
      Done := False;
      // 1. perform key in Focus Control
      if Assigned(FFocused) then
      begin
        FFocused.DialogKey(Key, Shift);
        if Key = 0 then
          Exit;
        FocusObj := FFocused.GetObject;
      end
      else
        FocusObj := nil;
      // 2. perform key in PopupMenu of Focus Control
      if (FocusObj is TControl) then
      begin
        FocusPopup := TControl(FocusObj).PopupMenu;
        if FocusPopup is TPopupMenu then
        begin
          TPopupMenu(FocusPopup).DialogKey(Key, Shift);
          if Key = 0 then
            Exit;
        end
        else
          FocusPopup := nil;
      end;
      // 3. perform key in other Menus
      for i := ChildrenCount - 1 downto 0 do
      if Children[i] <> FocusPopup then
      begin
        if Children[i] is TMainMenu then
          TMainMenu(Children[i]).DialogKey(Key, Shift)
        else if Children[i] is TPopupMenu then
          TPopupMenu(Children[i]).DialogKey(Key, Shift);
        if Key = 0 then
          Exit;
      end;
      // 4. perform key in other, no focus controls
      for i := ChildrenCount - 1 downto 0 do
      if Children[i] <> FocusObj then
      begin
        if Children[i].IsIControl then
          Children[i].AsIControl.DialogKey(Key, Shift);
        if Key = 0 then
          Exit;
      end;
      // 5. perform key in all ActionLists in Childrens
      TraverseChildren(self);
      // 6. perform key in all main menus and ActionLists in other forms
      OtherForms(True);
      OtherForms(False);
      if Done then Exit;
    end;

    { change focus } // DANN DAS ******************************************************
    if (Key = vkTab) then
    begin
      NewFocus := nil;
      Key := 0;
      List := TInterfaceList.Create;
      try
        GetTabOrderList(List, True);
        if ssShift in Shift then
          TabDirection := -1
        else
          TabDirection := 1;

        CurIdx := List.IndexOf(FFocused);
        for i := 0 to List.Count-1 do
        begin
          Inc(CurIdx, TabDirection);
          if (TabDirection > 0) and (CurIdx >= List.Count) then
            CurIdx := 0
          else
          if (TabDirection < 0) and (CurIdx < 0) then
            CurIdx := List.Count - 1;

          if IControl(List[CurIdx]).CheckForAllowFocus then
          begin
            NewFocus := IControl(List[CurIdx]);
            break;
          end;
        end;
      finally
        FreeAndNil(List);
      end;
      if Assigned(NewFocus) then
        NewFocus.SetFocus;
      Exit;
    end;

    { focused handler }  // ERST DAS *****************************************************
    if ((Key <> 0) or (KeyChar <> #0)) then
    begin
      if Assigned(FFocused) then
        FFocused.KeyDown(Key, KeyChar, Shift);
      if Assigned(FOnKeyDown) then
        FOnKeyDown(Self, Key, KeyChar, Shift);
    end;
  finally
    Application.FLastKeyPress := Now;
    Application.FLastUserActive := Application.FLastKeyPress;
  end;
end;
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:53 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