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
0005723 [JEDI VCL] 00 JVCL Components major always 2011-11-27 19:32 2012-09-10 14:15
Reporter Arioch View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0005723: JvCheckbox in JvCheckBox.pas is broken on transfering focus
Description The widget has LinkedControls list, which it tries to enable/disable wrt its checkmark toggle.

But it also tries to lend its focus to the 1st of them. And if check is clear, then it tries to Focus disabled control, which then throws an Exception.

(to reproduce it you should switch focus with tab / shift-tab, because mouse just checks the mark and control becomes enabled and focusing goes ok)

Looks like current code only function is just to find 1st TWinControl and unconditionally focus it, so i reworked it a bit.
Additional Information Proposed change:

procedure TJvCheckBox.SetFocus;
var
  I: Integer;
  TryControl: TJvLinkedControl;
// FocusLinkedControl: TWinControl;
begin
  inherited SetFocus;

  for I := 0 to LinkedControls.Count - 1 do begin
    TryControl := LinkedControls[I]; // let cache and speed up a bit
    if (loForceFocus in TryControl.Options) and (TryControl.Control is TWinControl) then
       with TWinControl(TryControl.Control) do
            if CanFocus then begin
               SetFocus;
               Break;
            end;
  end;
end;
Tags No tags attached.
Attached Files 7z file icon JVCL_5723.exe.7z [^] (1,742,503 bytes) 2012-02-22 22:12
7z file icon JVCL-0005723.sources.7z [^] (1,206 bytes) 2012-02-22 22:14

- Relationships

-  Notes
(0019142)
Arioch (developer)
2011-11-27 19:46

I wonder if enumerator-based for-in construct would be better for modern Delphies and there's sense to have IfDef-ed code ?

But probably not. For most time there would be 1 or at large just 3-4 linked controls, where overhead of creating two objects (GetEnumerable -> GetEnumerator) is not worth the candles. Though for-in is slick and elegant to read.
(0019169)
Arioch (developer)
2011-11-30 20:46

this was in Eclipse in "Steps to reproduce" section. Seems is not available in WWW:
=============================
Current code:

procedure TJvCheckBox.SetFocus;
var
  I: Integer;
  FocusLinkedControl: TControl;
begin
  inherited SetFocus;

  FocusLinkedControl := nil;
  I := 0;
  while (I < LinkedControls.Count) and not Assigned(FocusLinkedControl) do
  begin
    if (loForceFocus in LinkedControls[I].Options) and (LinkedControls[I].Control is TWinControl) then
      FocusLinkedControl := LinkedControls[I].Control;

    Inc(I);
  end;
  if Assigned(FocusLinkedControl) then
    TWinControl(FocusLinkedControl).SetFocus;
end;
(0019456)
obones (administrator)
2012-02-22 15:01

Please provide the zipped sources of a sample application showing this
(0019701)
Arioch (developer)
2012-04-15 15:46

bump
(0019925)
obones (administrator)
2012-06-12 16:03

This is now fixed in SVN

- Issue History
Date Modified Username Field Change
2011-11-27 19:32 Arioch New Issue
2011-11-27 19:36 Arioch Description Updated
2011-11-27 19:36 Arioch Additional Information Updated
2011-11-27 19:46 Arioch Note Added: 0019142
2011-11-30 20:46 Arioch Note Added: 0019169
2011-12-29 22:57 Arioch Note Added: 0019281
2011-12-29 22:57 Arioch Status new => closed
2011-12-29 22:57 Arioch Resolution open => fixed
2011-12-29 22:57 Arioch Fixed in Version => Daily / SVN
2011-12-29 22:58 Arioch Note Added: 0019282
2011-12-29 22:58 Arioch Status closed => feedback
2011-12-29 22:58 Arioch Resolution fixed => reopened
2011-12-29 22:58 Arioch Status feedback => new
2011-12-29 22:58 Arioch Note Deleted: 0019281
2011-12-29 22:58 Arioch Note Deleted: 0019282
2012-02-22 15:01 obones Note Added: 0019456
2012-02-22 15:01 obones Status new => feedback
2012-02-22 22:12 Arioch File Added: JVCL_5723.exe.7z
2012-02-22 22:14 Arioch File Added: JVCL-0005723.sources.7z
2012-04-15 15:46 Arioch Note Added: 0019701
2012-06-11 17:39 obones Status feedback => acknowledged
2012-06-12 16:03 obones Note Added: 0019925
2012-06-12 16:03 obones Status acknowledged => resolved
2012-06-12 16:03 obones Resolution reopened => fixed
2012-06-12 16:03 obones Assigned To => obones
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46


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