mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 03:48:08 +02:00
Revert r49699 #57795c6d42, "LCL: Prevent opening custom color selection dialog in ColorBox wrongly."
git-svn-id: trunk@49869 -
This commit is contained in:
parent
2e36d4e2c3
commit
e2932283ec
@ -40,7 +40,6 @@ type
|
||||
cbPrettyNames, // use good looking color names - like Red for clRed
|
||||
cbCustomColors); // call OnGetColors after all other colors processing
|
||||
TColorBoxStyle = set of TColorBoxStyles;
|
||||
TColorBoxCloseKey = (cbckNone, cbckReturn, cbckOther);
|
||||
TGetColorsEvent = procedure(Sender: TCustomColorBox; Items: TStrings) of object;
|
||||
|
||||
TCustomColorBox = class(TCustomComboBox)
|
||||
@ -52,7 +51,6 @@ type
|
||||
FOnGetColors: TGetColorsEvent;
|
||||
FStyle: TColorBoxStyle;
|
||||
FSelected: TColor;
|
||||
FCloseMode: TColorBoxCloseKey;
|
||||
function GetColor(Index : Integer): TColor;
|
||||
function GetColorName(Index: Integer): string;
|
||||
function GetSelected: TColor;
|
||||
@ -70,9 +68,7 @@ type
|
||||
procedure Loaded; override;
|
||||
procedure InitializeWnd; override;
|
||||
procedure DoGetColors; virtual;
|
||||
procedure DropDown; override;
|
||||
procedure CloseUp; override;
|
||||
procedure KeyDownBeforeInterface(var Key: Word; Shift: TShiftState); override;
|
||||
function PickCustomColor: Boolean; virtual;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -670,36 +666,10 @@ begin
|
||||
OnGetColors(Self, Items)
|
||||
end;
|
||||
|
||||
procedure TCustomColorBox.KeyDownBeforeInterface(var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
if DroppedDown then
|
||||
begin
|
||||
if Key = VK_Return then
|
||||
FCloseMode := cbckReturn
|
||||
else
|
||||
FCloseMode := cbckOther; // other keys: Escape, Tab, Space etc.
|
||||
end;
|
||||
inherited KeyDownBeforeInterface(Key, Shift);
|
||||
end;
|
||||
|
||||
procedure TCustomColorBox.DropDown;
|
||||
begin
|
||||
FCloseMode := cbckNone;
|
||||
inherited DropDown;
|
||||
end;
|
||||
|
||||
procedure TCustomColorBox.CloseUp;
|
||||
var
|
||||
mp, co: TPoint;
|
||||
cr: TRect;
|
||||
begin
|
||||
mp := Mouse.CursorPos;
|
||||
co := ClientOrigin;
|
||||
cr := Rect(co.x, co.y+Height+BorderWidth, co.x+Width, co.y+Height+ItemHeight);
|
||||
if (cbCustomColor in Style) and (ItemIndex = 0) and (
|
||||
(PtInRect(cr, mp) and (FCloseMode <> cbckOther)) or (FCloseMode = cbckReturn)
|
||||
) then
|
||||
PickCustomColor; // custom color has been selected
|
||||
if (cbCustomColor in Style) and (ItemIndex = 0) then // custom color has been selected
|
||||
PickCustomColor;
|
||||
if ItemIndex <> -1 then
|
||||
Selected := Colors[ItemIndex];
|
||||
inherited CloseUp;
|
||||
|
Loading…
Reference in New Issue
Block a user