Another fix of Delphi code – Click on the ListView

My customer found another but at Delphi application:

TListView Bug

 

If you click at TListView on the empty are, last item get automatically selected and events as  OnClick and OnItemClick are called.

Well it can be nice feature for someone, but it’s not really logical .. for example if you have open keyboard and you want to hide it, by clicking at the empty area.

There is no settings to tun this behavior off as it’s hard coded.

The problem is at FMX.ListView.pas unit at FindItemAbsoluteAt procedure, line 4060.

This code:

if ViewAt >= HeightSums[HeightSums.Count - 1] then
 Exit(HeightSums.Count - 1);

Replace with this code:

 if ViewAt >= HeightSums[HeightSums.Count - 1]+GetItemHeight(HeightSums.Count-1) then
 Exit(-1);

And the system will start to work logically.

You can download modified unit here, just include into your project.

One comment

  1. brent says:

    Thanks, I was looking for this the other day. I found your site from fmxexpress.com because of some other article and found this fix.

Leave a Reply to brent Cancel reply

Your email address will not be published. Required fields are marked *