mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 14:11:25 +02:00
lcl: always close/prevent dropdown when pressing Return, ESC or TAB. Code cleanup
git-svn-id: trunk@34373 -
This commit is contained in:
parent
8ad1d066b9
commit
7b40b6ff7e
@ -475,42 +475,36 @@ end;
|
|||||||
|
|
||||||
procedure TCustomComboBox.KeyDown(var Key: Word; Shift: TShiftState);
|
procedure TCustomComboBox.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
var
|
var
|
||||||
skip : Boolean;
|
Skip, UserDropDown, PreventDropDown: Boolean;
|
||||||
UserDropDown: boolean;
|
|
||||||
begin
|
begin
|
||||||
Skip := False;
|
Skip := False;
|
||||||
UserDropDown := ((Shift *[ssAlt] = [ssAlt]) and (Key = VK_DOWN));
|
UserDropDown := ((Shift *[ssAlt] = [ssAlt]) and (Key = VK_DOWN));
|
||||||
|
PreventDropDown := Key in [VK_TAB, VK_RETURN, VK_ESCAPE];
|
||||||
|
if PreventDropDown then
|
||||||
|
DroppedDown := False;
|
||||||
if AutoDropDown or UserDropDown or FReturnArrowState then
|
if AutoDropDown or UserDropDown or FReturnArrowState then
|
||||||
begin
|
begin
|
||||||
case Key of
|
if PreventDropDown then
|
||||||
VK_TAB,VK_RETURN:
|
begin
|
||||||
begin
|
if FReturnArrowState then
|
||||||
|
|
||||||
if FReturnArrowState = True then
|
|
||||||
begin
|
|
||||||
SetArrowKeysTraverseList(False); //we need this here, else we cannot traverse popup list
|
|
||||||
FReturnArrowState := False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
DroppedDown := False;
|
|
||||||
end;
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
if ArrowKeysTraverseList = False then
|
ArrowKeysTraverseList := False; //we need?? this here, else we cannot traverse popup list
|
||||||
begin
|
FReturnArrowState := False;
|
||||||
SetArrowKeysTraverseList(True); //we need this here, else we cannot traverse popup list
|
|
||||||
FReturnArrowState := True;
|
|
||||||
Skip := True;
|
|
||||||
end;
|
|
||||||
//AutoDropDown := True;
|
|
||||||
DroppedDown := True;
|
|
||||||
if UserDropDown then
|
|
||||||
Skip := True;
|
|
||||||
end;
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if not ArrowKeysTraverseList then
|
||||||
|
begin
|
||||||
|
ArrowKeysTraverseList := True; //we need?? this here, else we cannot traverse popup list
|
||||||
|
FReturnArrowState := True;
|
||||||
|
Skip := True;
|
||||||
|
end;
|
||||||
|
DroppedDown := True;
|
||||||
|
if UserDropDown then
|
||||||
|
Skip := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Skip then
|
if Skip then
|
||||||
Key := VK_UNKNOWN
|
Key := VK_UNKNOWN
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user