Commit 62711a2b authored by Bart B's avatar Bart B 🐞
Browse files

TCheckListBox: when user presses spacebar:

- if ItemIndex = -1: set it to 0 and fire OnClick;
- fire OnClickCheck.
Issue #24695.

git-svn-id: trunk@47992 -
parent 82b49e88
......@@ -299,12 +299,23 @@ procedure TCustomCheckListBox.KeyDown(var Key: Word; Shift: TShiftState);
var
Index: Integer;
begin
if (Key = VK_SPACE) and (Shift=[]) and (ItemIndex >= 0) and ItemEnabled[ItemIndex] then
if (Key = VK_SPACE) and (Shift=[]) then
begin
Index := ItemIndex;
Checked[Index] := not Checked[Index];
ItemClick(Index);
Key := VK_UNKNOWN;
//Delphi (7) sets ItemIndex to 0 in this case and fires OnClick
if (ItemIndex < 0) and (Items.Count >= 0) then
begin
ItemIndex := 0;
Click;
end;
if (ItemIndex >= 0) and ItemEnabled[ItemIndex] then
begin
Index := ItemIndex;
Checked[Index] := not Checked[Index];
ClickCheck;
//ToDo: does Delphi fire OnItemClick and in the same order?
ItemClick(Index);
Key := VK_UNKNOWN;
end;
end else
inherited KeyDown(Key,Shift);
end;
......
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