lcl: TSpeedButton should generate a click event if it changes Down state in spite of csClicked state (fixes issue #0018010)

git-svn-id: trunk@28394 -
This commit is contained in:
paul 2010-11-22 06:15:27 +00:00
parent a2e75a4b8d
commit ec1fc668c9

View File

@ -753,6 +753,7 @@ end;
procedure TCustomSpeedButton.WMLButtonUp(var Message: TLMLButtonUp); procedure TCustomSpeedButton.WMLButtonUp(var Message: TLMLButtonUp);
var var
OldState: TButtonState; OldState: TButtonState;
NeedClick: Boolean;
begin begin
//DebugLn('TCustomSpeedButton.WMLButtonUp A ',DbgSName(Self),' csCaptureMouse=',DbgS(csCaptureMouse in ControlStyle),' csClicked=',DbgS(csClicked in ControlState)); //DebugLn('TCustomSpeedButton.WMLButtonUp A ',DbgSName(Self),' csCaptureMouse=',DbgS(csCaptureMouse in ControlStyle),' csClicked=',DbgS(csClicked in ControlState));
if (csCaptureMouse in ControlStyle) and (mbLeft in CaptureMouseButtons) then if (csCaptureMouse in ControlStyle) and (mbLeft in CaptureMouseButtons) then
@ -763,6 +764,8 @@ begin
MouseCapture := False; MouseCapture := False;
end; end;
NeedClick := False;
if not (csDesigning in ComponentState) and FDragging then if not (csDesigning in ComponentState) and FDragging then
begin begin
OldState := FState; OldState := FState;
@ -778,6 +781,7 @@ begin
if (Message.XPos >= 0) and (Message.XPos < Width) and (Message.YPos >= 0) and (Message.YPos < Height) then if (Message.XPos >= 0) and (Message.XPos < Width) and (Message.YPos >= 0) and (Message.YPos < Height) then
begin begin
SetDown(not FDown); SetDown(not FDown);
NeedClick := True;
end; end;
end; end;
@ -791,10 +795,13 @@ begin
begin begin
//DebugLn('TCustomSpeedButton.WMLButtonUp C'); //DebugLn('TCustomSpeedButton.WMLButtonUp C');
// Important: Calling Click can invoke modal dialogs, so call this as last // Important: Calling Click can invoke modal dialogs, so call this as last
NeedClick := False;
Click; Click;
end; end;
end; end;
if NeedClick then
Click;
//DebugLn('TCustomSpeedButton.WMLButtonUp END'); //DebugLn('TCustomSpeedButton.WMLButtonUp END');
end; end;