View Issue Details

IDProjectCategoryView StatusLast Update
0001619JEDI VCL00 JVCL Componentspublic2004-04-11 02:21
ReporterglchapmanAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version 
Target VersionFixed in Version 
Summary0001619: TJvCustomItemViewer: SelectedIndex incorrect in OnClick handler
DescriptionTJvCustomItemViewer updates its SelectedIndex property in its MouseUp override. Unfortunately, TControl.Click is called before TControl.MouseUp (in D5 anyway), so at the time an OnClick handler is called, SelectedIndex still has its old value. You can see this with the TJvOwnerDrawViewer in the JvItemViewer demo -- the status bar does not update until the second click of a particular item.
Additional InformationLooking further into this, I think the real problem may be that TJvOwnerDrawViewer does not publish OnItemChanged (and OnItemChanging and several other events). If it did, instead of using an OnClick handler, the demo could have:

procedure TfrmMain.DoItV3ItemChanged(Sender: TObject; Item: TJvViewerItem);
begin
  if Assigned(Item) and (cdsSelected in Item.State) then
    StatusBar1.Panels[0].Text := ColorToString(TColor(Item.Data));
end;

TagsNo tags attached.

Activities

user72

2004-04-10 12:05

  ~0003787

Or you could use OnMouseUp...

The problem is that I can't change SelectedIndex in MouseDown because that causes problems when doing MouseDown on one item but MouseUp on another and it also messes up multi-select in some cases.

Publishing the mentioned events could also be a good choice but the base problem remains the same: you can't use OnClick to determine the currently selected item, you generally need to use OnMouseUp.

anonymous

2004-04-10 16:33

viewer   ~0003792

Last edited: 2004-04-10 16:34

Well, whatever you decide, I think you should update the demo to show the recommended way to do this sort of thing (I have no immediate plans to use this control. I was just curious what it was, so I ran the demo and noticed the problem.) (This by glchapman, who forgot to log in again)

edited on: 04-10-04 16:34

user72

2004-04-11 02:21

  ~0003793

> I think you should update the demo
Good suggestion. Will do. Wil also have a look at the publishing of the suggested events.

Issue History

Date Modified Username Field Change
2004-04-10 09:35 glchapman New Issue
2004-04-10 12:05 user72 Note Added: 0003787
2004-04-10 16:33 anonymous Note Added: 0003792
2004-04-10 16:34 anonymous Note Edited: 0003792
2004-04-11 02:21 user72 Status new => resolved
2004-04-11 02:21 user72 Resolution open => no change required
2004-04-11 02:21 user72 Assigned To => user72
2004-04-11 02:21 user72 Note Added: 0003793