Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003761 [JEDI VCL] 00 JVCL Components minor always 2006-06-11 01:02 2008-10-14 02:25
Reporter bunglehead View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.20
Summary 0003761: JvDocking focus bug (VID and .NET style)
Description Tab Container doesn't focus properly..
You can try it on VIDDemo example..

1. Show 3 docking forms (at least). For example Project Explorer, Properties and Toolbox.
2. Dock two of them into a tab container, then dock this container.
3. Now set focus on third (not tabbed) form and dock it to then container
4. Container caption didn't highlight. And doesn't respond on mouse clicks and focusing of tabbed forms.
Additional Information
Tags No tags attached.
Attached Files zip file icon JediDockVSNET.zip [^] (20,121 bytes) 2007-03-07 13:34
zip file icon JvDocking.zip [^] (135,781 bytes) 2007-03-20 09:25
? file icon JvDockVIDStyle.patch [^] (1,693 bytes) 2008-03-07 22:20
? file icon JvDockVIDStyle2.patch [^] (1,634 bytes) 2008-03-13 14:53

- Relationships

-  Notes
(0009621)
obones (administrator)
2006-06-22 08:11

Yes, it does not highlight, but it does respond to mouse clicks on tabs.
Please try with todays snapshot:

http://jvcl.sf.net/daily/ [^]
(0009631)
bunglehead (reporter)
2006-06-22 16:16

No, no..I meant caption doesn't respond by highlighting when you click on it..
Tabs work of course..
It isn't a big problem, but users don't understand it)
(0010492)
obones (administrator)
2007-01-03 12:07

Can you provide the zipped sources of a demo application showing what you mean?
(0011296)
bunglehead (reporter)
2007-03-07 13:34

You can try this with src provided. I've tried it just now with latest snapshot, problem remains the same.
Dock two froms to each other to get tab container.
Then dock this container to left side of a main form.
After docking title bar of tab container remains inactive, but all tab functions are ok.
After Minimizing -> Maximizing everything become good.
(0011459)
Kiriakos (reporter)
2007-03-18 17:03

In my private copy of JvDockVIDStyle I have made the following changes to deal with focus problems:

a) In TJvDockVIDTabPageControl.Change I have commented out 5 lines as below:

procedure TJvDockVIDTabPageControl.Change;
begin
  Assert(Assigned(ParentForm));
  inherited Change;

  { During closing/undocking of a form,
    ActivePage is actually going to be wrong.
    See above in DoRemoveDockClient for where we fix
    this problem. }
  ParentForm.Caption := ActivePage.Caption;

  if ParentForm.HostDockSite is TJvDockCustomPanel then
  begin
// if ParentForm.Visible and ParentForm.CanFocus then
// ParentForm.SetFocus;
    ParentForm.HostDockSite.Invalidate;
  end;
// if (ActivePage <> nil) and (ActivePage.Visible) and (ActivePage.CanFocus) then
// if ParentForm.Visible and ParentForm.CanFocus then
// ActivePage.SetFocus;
end;


b) In TJvDockTabPanel.MouseDown I have added 8 lines

procedure TJvDockTabPanel.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
var
  Ctrl: TControl;
  Index: Integer;
  Msg: TWMMouse;
  Sheet: TJvDockVIDTabSheet;
begin
  inherited MouseDown(Button, Shift, X, Y);
  if Page = nil then
    Exit;

  Index := GetPageIndexFromMousePos(X, Y);
  if Index >= 0 then
  begin
    // added
    if Page.ParentForm.HostDockSite is TJvDockCustomPanel then
    with Page do begin
      if ParentForm.Visible and ParentForm.CanFocus then
        ParentForm.SetFocus;
      if (ActivePage <> nil) and (ActivePage.Visible) and (ActivePage.CanFocus) then
        if ParentForm.Visible and ParentForm.CanFocus then
          ActivePage.SetFocus;
    end;
    // added


Does this resolve your problem?

Analysis:

Further down in TJvDockTabPanel.MouseDown there is the code:
  Page.ActivePageIndex := Index;
This shows the new page of TabPanel sets the focus to the first selectable control of the docked form.
Just below this statement there the line:
  Page.Change;
This triggers the change method that is listed at the top of this comment. The commented out lines remove the focus from the docked form and set to the tab page itself. This creates the focus problems.
(0011477)
bunglehead (reporter)
2007-03-19 07:58

No, this doesn't resolve it. Problem remains the same.
(0011493)
Kiriakos (reporter)
2007-03-19 19:55

OK. The submitted changes solve a different focus problem.

Please try the following:

In unit JvDockVIDStyle add these lines at the end of TJvDockVIDPanel.CustomDockDrop

    if (Source.Control is TJvDockTabHostForm) and
      (TJvDockTabHostForm(Source.Control).GetActiveDockForm <> nil) and
      TJvDockTabHostForm(Source.Control).GetActiveDockForm.CanFocus then
      TJvDockTabHostForm(Source.Control).GetActiveDockForm.SetFocus;


Optionally (this is for when you undock tabbed forms) add the following method to TJvDockTabHostForm in unit JvDockControlForm

declaration
    procedure DoDock(NewDockSite: TWinControl; var ARect: TRect); override;


procedure TJvDockTabHostForm.DoDock(NewDockSite: TWinControl; var ARect: TRect);
begin
  inherited;
  if (GetActiveDockForm <> nil) and
      GetActiveDockForm.CanFocus then
      GetActiveDockForm.SetFocus;
end;

Please report back.
(0011494)
Kiriakos (reporter)
2007-03-19 20:47

Corrected TJvDockTabHostForm.DoDock below. Please use this one instead of the one given above.

procedure TJvDockTabHostForm.DoDock(NewDockSite: TWinControl; var ARect: TRect);
begin
  inherited;
  if not JvGlobalDockIsLoading and
    (GetActiveDockForm <> nil) and
    GetParentForm(Self).Visible and
    GetActiveDockForm.CanFocus then
       GetActiveDockForm.SetFocus;
end;
(0011495)
Kiriakos (reporter)
2007-03-19 21:11

Also, make sure you set the Dock Server AutoFocusDockedForm property to True. With the combined changes I have presented I get the desired focus behaviour in the scenarios you described.
(0011520)
Kiriakos (reporter)
2007-03-20 09:31

I have done some more work on the Focus issue and attached the private copies of modified JvDocking files in the attached JvDocking.zip file. To test use the Advanced Demo:

a) Copy the zipped files to the directory of the Demo.

b) Modify TRunTimeForm.Create in the demo so that the memo component is displayed in the form and you can observe whether it receives the focus or not.

  with TMemo.Create(Self) do
  begin
    Parent := Self; //added
    Align := alClient;
    BorderStyle := bsNone;
  end;

c) Test with the VID VSNet styles

If the changes produce the desired results or at least improve over the current situation I will submit pathches to Jvcl.
(0011521)
bunglehead (reporter)
2007-03-20 13:03

Hello, I've tried it all. Well, it solves something it's true, but problem still exists. Sometimes caption of pagecontrol is not highlighted. But now it goes better. Vista style of dragging is very pretty, but it's must be an option (published property) I think. And it isn't included in SVN yet...
(0011522)
bunglehead (reporter)
2007-03-20 13:19

With a new dragging there're some unnecessary flashing of alphablended rectangle. This blinking goes far out of window - container of DockServer..
Maybe it's a common JvDocking issue, and isn't the result of your suggestions..
(0011610)
remkobonte (developer)
2007-03-26 15:55

Is the problem in this specific case maybe just the "if ActiveControl = Control then" check in TJvDockVIDTree.DrawDockGrabber?

ie, if you change it to

"if TWinControl(Control).ContainsControl(GetActiveControl) then" it works for me.
(0011634)
bunglehead (reporter)
2007-03-27 12:10

No, it doesn't help always. Sometimes I got the incorrect font color (when the same condition used for font color preselection).
(0011635)
remkobonte (developer)
2007-03-27 14:13

Could you try to reproduce a case when it's not correct? I'll inspect the changes by Kiriakos in the mean time :)
(0011645)
bunglehead (reporter)
2007-03-28 01:13

I'm sorry. I meant color of close and hide buttons on a grabber. I can't reproduce it all the time..Same as my initial issue (0003761). Kiriakos' changes don't resolve it all. Your suggestion is much more light. It eliminates focus issue, but not completely (it remains sometimes after multiple minimize/restore operations). If you could fix color of buttons this solution must be temporarely used.
Look at another Kiriakos suggestion on using Vista's alpha rectangle when dragging instead of traditional (in JvDocking.zip). It isn't a finished work yet. Cause of flickering of this rectangle. But after some work it solud live as an aditional property I think.
(0011675)
bunglehead (reporter)
2007-03-29 12:15

I think this is fixed now (at 03/29/2007). But another behaviour changed: when main form (Container of all JvDocking components) lost focus, grabber remains highlighted. Is it a desired behaviour? I think previous versions (where grabber was disabled when main form lost focus) were better in this part.
(0011676)
remkobonte (developer)
2007-03-29 12:45

Thanks for the feedback, I didn't think of that. Should now be fixed in Rev 11245.
(0011704)
bunglehead (reporter)
2007-03-30 11:52

Yes, I thought about this solution yesterday. But:
It works only if Control in your IsActive condition contain a control that can catch a focus (such as in Advancepro demo example). If dock form has no focusable objects grabber doesn't repaint correctly.
And this code is unsafe. If you want to use this you should split it in something like that to prevent AV on getting Focused property:

        if Assigned(Screen.ActiveControl) then
           IsActive := Screen.ActiveControl.Focused and
                       Control.ContainsControl(Screen.ActiveControl)
        else
           IsActive := False;

But first of all a patch needed to resolve this issue completely. I'm trying to find it too.
(0011738)
remkobonte (developer)
2007-04-01 05:22

That is not correct, I think:

* If the dock form contains no focusable objects and you or the system focuses the dock form then the Screen.ActiveControl will be the dock form itself; and the ContainsControl method will return True in this case.

* JVCL uses Delphi's short-circuit Boolean evaluation that means strict left-to-right evaluation that stops as soon as the result of the entire expression is determined.

Thus if "Assigned(Screen.ActiveControl)" is False then "Screen.ActiveControl.Focused" will not be evaluated.
(0011743)
bunglehead (reporter)
2007-04-01 13:26

About the first:
 may be it isn't serious, but when dockform contains no focusable objects in
 doesn't catch focus (I might be wrong but simple clicking on it hasn't any
 consequence such as grabber highlighting; but clicking on grabber active it
 normally.

About short boolean evaluation:
 I did not know that it's a default JVCL compiler configuration.
 What about debug mode? By myself I prefer splitting in such pointer operation
 cases to be sure.
(0012153)
Kiriakos (reporter)
2007-04-17 18:38

Remko

The new JvDocking code is working fine except for the change you made in TJvDockTabPanel.MouseDown following my suggestion which does not always pass the focus to the controls of the form when you click the tab. I got a better solution which always works. It also focuses correctly when you click the tab of an already selected form. Here is the amended part of TJvDockTabPanel.MouseDown.

procedure TJvDockTabPanel.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
var
  Ctrl: TControl;
  Index: Integer;
  Msg: TWMMouse;
  Sheet: TJvDockVIDTabSheet;
  AParentForm: TCustomForm;
begin
  inherited MouseDown(Button, Shift, X, Y);
  if Page = nil then
    Exit;

  Index := GetPageIndexFromMousePos(X, Y);
  if Index >= 0 then
  begin
    if Index <> Page.ActivePageIndex then
    begin
      Sheet := Page.ActiveVIDPage;
      Page.ActivePageIndex := Index;
      Sheet.SetSheetSort(Sheet.Caption);
      Page.ActiveVIDPage.SetSheetSort(Page.ActiveVIDPage.Caption);
      Page.Change;
      Invalidate;
    end;
    // Added code
    if Assigned(Page.ActivePage) and Page.ActivePage.CanFocus then
    begin
      AParentForm := GetParentForm(Page);
      if Assigned(AParentForm) then begin
        Page.SelectFirst;
        AParentForm.SetFocus;
      end;
    end;



Also please take a look at reports 4108 and 4109.
(0012154)
Kiriakos (reporter)
2007-04-17 18:45

Remko,

Also outstanding JvDocking patches are in reports 3998 and 4076.

Many thanks!
(0014224)
obones (administrator)
2008-02-21 03:30

Any news on this?
(0014285)
Kiriakos (reporter)
2008-03-07 22:23

I have attached a patch file with my changes to JvDockVIDStyle.pas. The changes are related to this focus issue. I have been using these changes for ages in the open source project PyScripter (pyscripter.googlepages.com, pyscripter.googlecode.com) and have not heard of any problems.
(0014287)
obones (administrator)
2008-03-10 01:59

Thanks, but the patch seems to be done on a very old version of the file, in a format that TortoiseSVN cannot understand. And I even suspect it's done in reverse with the "--" lines being what you want added and not removed.
Can you recreate the patch from the current version of the file from subversion?
Thanks in advance.
(0014294)
Kiriakos (reporter)
2008-03-13 14:54

Added a new patch, which is against the SVN version. I hope the format is OK...
(0014856)
obones (administrator)
2008-10-14 02:24

This is in SVN since March, sorry for the delay in updating the issue.

- Issue History
Date Modified Username Field Change
2006-06-11 01:02 bunglehead New Issue
2006-06-11 01:03 bunglehead Issue Monitored: bunglehead
2006-06-11 01:12 bunglehead Issue End Monitor: bunglehead
2006-06-22 08:11 obones Note Added: 0009621
2006-06-22 08:11 obones Status new => feedback
2006-06-22 16:16 bunglehead Note Added: 0009631
2007-01-03 12:07 obones Note Added: 0010492
2007-03-07 13:34 bunglehead Note Added: 0011296
2007-03-07 13:34 bunglehead File Added: JediDockVSNET.zip
2007-03-18 17:03 Kiriakos Note Added: 0011459
2007-03-19 07:58 bunglehead Note Added: 0011477
2007-03-19 19:55 Kiriakos Note Added: 0011493
2007-03-19 20:47 Kiriakos Note Added: 0011494
2007-03-19 21:11 Kiriakos Note Added: 0011495
2007-03-20 09:25 Kiriakos File Added: JvDocking.zip
2007-03-20 09:31 Kiriakos Note Added: 0011520
2007-03-20 13:03 bunglehead Note Added: 0011521
2007-03-20 13:19 bunglehead Note Added: 0011522
2007-03-26 15:55 remkobonte Note Added: 0011610
2007-03-27 12:10 bunglehead Note Added: 0011634
2007-03-27 14:13 remkobonte Note Added: 0011635
2007-03-28 01:13 bunglehead Note Added: 0011645
2007-03-29 12:15 bunglehead Note Added: 0011675
2007-03-29 12:45 remkobonte Note Added: 0011676
2007-03-30 11:52 bunglehead Note Added: 0011704
2007-04-01 05:22 remkobonte Note Added: 0011738
2007-04-01 13:26 bunglehead Note Added: 0011743
2007-04-17 18:38 Kiriakos Note Added: 0012153
2007-04-17 18:45 Kiriakos Note Added: 0012154
2008-02-21 03:30 obones Note Added: 0014224
2008-03-07 22:20 Kiriakos File Added: JvDockVIDStyle.patch
2008-03-07 22:23 Kiriakos Note Added: 0014285
2008-03-10 01:59 obones Note Added: 0014287
2008-03-13 14:53 Kiriakos File Added: JvDockVIDStyle2.patch
2008-03-13 14:54 Kiriakos Note Added: 0014294
2008-10-14 02:24 obones Status feedback => resolved
2008-10-14 02:24 obones Fixed in Version => 3.34
2008-10-14 02:24 obones Resolution open => fixed
2008-10-14 02:24 obones Assigned To => obones
2008-10-14 02:24 obones Note Added: 0014856


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker