Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Detect when a floating docpanel gets focus?

I have several dock panels that can be undocked, and will be undocked for the sake of this post.  Inside each is a TTreeView and a toolbar.  I have to update a panel in another doc panel depending on which node of which treeview is selected.  This is fine as long as the user changes the currently selected node in either of the tree views.  If a user goes back and forth between the treeviews without changing the selected node, I cannot find an event that tells me the focus has changed so that I can update the panel based on which treeview.  The OnEnter does not trigger for the treeviews nor for the dock panels.  The Docksite OnChange also does not trigger.  Nor does the OnMouseDown event in the doc panel, but does for the treeview.

Is there a way to know when a floating dock panel gets focus other than using the OnMouseDown event on every control within each dock panel?

Comments

  • 3 Comments sorted by Votes Date Added
  • For the moment, I added what I needed to detect focus change to the OnMouseActivate event for each toolbar and each treeview.
  • edited April 2020 Posts: 0 Accepted Answer Vote Up0Vote Down
    OnEnter works fine for panels, but only inside a form. This is Delphi's rule, since every form can have its own ActiveControl, which is not changed when the form itself looses focus.

    To handle floating forms you can use DockManager.OnCreateFloatingSite event, in which you have access to implicitly created docking site for floating window and its parent Site.FloatingForm. Here you can set form's event handlers for standard event like OnActivate, OnShow, ect...

    A little hack is required to get access to form events (I'll publish form events to eliminate the need of this hack):

    type
      TFormHack = class(TCustomForm);

    procedure TForm.DockManagerCreateFloatingSite(Sender: TObject;
      ASite: TLMDDockSite);
    begin
      TFormHack(ASite.FloatingForm).OnActivate := MyActivateHandler;
    end;



  • Thanks for the detailed info and interim hack :)
Sign In or Register to comment.