Commit c0c30424 authored by Werner Pamler's avatar Werner Pamler
Browse files

LCL/TListView: More complete fix of issue #39708, based on patch by d7_2_laz...

LCL/TListView: More complete fix of issue #39708, based on patch by d7_2_laz (https://forum.lazarus.freepascal.org/index.php/topic,59024.msg441180.html#msg441180).
parent 284c9802
......@@ -331,11 +331,13 @@ begin
// checkbox
if Checkboxes then
DoItemChecked(Item);
// end editing
if IsEditing then
HideEditor;
if (IsEditing and OwnerData) then
if (nm^.iItem = -1) And (FSelectedIdx<>-1) then
if TWSCustomListViewClass(WidgetSetClass).MustHideEditor(self, FSelectedIdx) then
HideEditor;
// focus
if (nm^.uOldState and LVIS_FOCUSED) <> (nm^.uNewState and LVIS_FOCUSED) then
begin
......
......@@ -200,6 +200,7 @@ type
class function GetFirstSelected(const ALV: TCustomListView): TListItem; override;
class procedure InitMultiSelList(const ALV: TCustomListView; AEnable: Boolean); override;
class procedure UpdateMultiSelList(const ALV: TCustomListView; AItem: TListItem; Add: Boolean); override;
class function MustHideEditor(const ALV: TCustomListView; ASelectedIdx: Integer): Boolean; override;
end;
{ TWin32WSListView }
......
......@@ -60,6 +60,7 @@ var
ListViewWindProcInfo: record
ActiveListView: TCustomListView;
NoMouseUp: Boolean;
ClickedIdx: Integer;
end;
function ListViewParentMsgHandler(const AWinControl: TWinControl; Window: HWnd;
......@@ -833,6 +834,12 @@ begin
ListView := TListView(WindowInfo^.WinControl);
ListItem := ListView.GetItemAt(GET_X_LPARAM(LParam), GET_Y_LPARAM(LParam));
if (Msg = WM_LBUTTONDOWN) or (Msg = WM_RBUTTONDOWN) then
if ListItem = nil then
ListViewWindProcInfo.ClickedIdx := -1
else
ListViewWindProcInfo.ClickedIdx := ListItem.Index;
if Msg = WM_LBUTTONDOWN
then AMsg := LM_LBUTTONUP
else AMsg := LM_RBUTTONUP;
......@@ -1508,3 +1515,9 @@ class procedure TWin32WSCustomListView.UpdateMultiSelList(const ALV: TCustomList
begin
end;
class function TWin32WSCustomListView.MustHideEditor(const ALV: TCustomListview;
ASelectedIdx: Integer): Boolean;
begin
result := ASelectedIdx <> ListViewWindProcInfo.ClickedIdx;
end;
......@@ -183,6 +183,8 @@ type
class function GetFirstSelected(const ALV: TCustomListView): TListItem; virtual;
class procedure InitMultiSelList(const ALV: TCustomListView; AEnable: Boolean); virtual;
class procedure UpdateMultiSelList(const ALV: TCustomListView; AItem: TListItem; Add: Boolean); virtual;
class function MustHideEditor(const ALV: TCustomListView; ASelectedIdx: Integer): Boolean; virtual;
end;
TWSCustomListViewClass = class of TWSCustomListView;
......@@ -902,6 +904,12 @@ begin
end;
end;
class function TWSCustomListView.MustHideEditor(const ALV: TCustomListView;
ASelectedIdx: Integer): Boolean;
begin
Result := false;
end;
{ TWSProgressBar }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment