LCL, ObjectInspector: Prevent triggering double-click when expanding ComboBox quickly. Issue #19918, patch from Flávio Etrusco

git-svn-id: trunk@43642 -
This commit is contained in:
juha 2014-01-04 14:17:24 +00:00
parent 00ae8366f0
commit dfd9836690
5 changed files with 10 additions and 62 deletions

View File

@ -291,7 +291,7 @@ type
FTopY: integer; FTopY: integer;
FDrawHorzGridLines: Boolean; FDrawHorzGridLines: Boolean;
FActiveRowBmp: TCustomBitmap; FActiveRowBmp: TCustomBitmap;
FFirstClickTime: TDateTime; FFirstClickTime: DWORD;
FKeySearchText: string; FKeySearchText: string;
// hint stuff // hint stuff
@ -1499,8 +1499,12 @@ begin
if (Button=mbLeft) then begin if (Button=mbLeft) then begin
if (Shift=[ssCtrl,ssLeft]) then if (Shift=[ssCtrl,ssLeft]) then
DoCallEdit(oiqeShowValue) DoCallEdit(oiqeShowValue)
else if (FFirstClickTime<>0) and (Now-FFirstClickTime<(1/86400*0.4)) then else if (FFirstClickTime<>0) and (GetTickCount <= FFirstClickTime + GetDoubleClickTime)
ValueEditDblClick(Sender); and (not ValueComboBox.DroppedDown) then
begin
FFirstClickTime:=0;
ToggleRow;
end;
end; end;
end; end;
@ -2016,7 +2020,7 @@ begin
HideHint; HideHint;
if Button=mbLeft then begin if Button=mbLeft then begin
FFirstClickTime:=Now; FFirstClickTime:=GetTickCount;
if Cursor=crHSplit then begin if Cursor=crHSplit then begin
FDragging:=true; FDragging:=true;
end end

View File

@ -1701,16 +1701,7 @@ begin
WM_LBUTTONDOWN: WM_LBUTTONDOWN:
begin begin
if (MouseDownCount < 1) or (MouseDownCount > 4) then MouseDownCount := 1; if (MouseDownCount < 1) or (MouseDownCount > 4) then MouseDownCount := 1;
// if mouse-click, focus-change, mouse-click, cursor hasn't moved: if (MouseDownWindow = Window)
// simulate double click, assume focus change due to first mouse-click
if (MouseDownFocusStatus = mfFocusChanged) and (MouseDownFocusWindow = Window)
and (GetTickCount - MouseDownTime <= GetDoubleClickTime)
and CheckMouseMovement then
begin
inc(MouseDownCount);
PostMessage(Window, WM_LBUTTONDBLCLK, WParam, LParam);
end
else if (MouseDownWindow = Window)
and (GetTickCount - MouseDownTime <= GetDoubleClickTime) and (GetTickCount - MouseDownTime <= GetDoubleClickTime)
and CheckMouseMovement then and CheckMouseMovement then
inc(MouseDownCount) inc(MouseDownCount)
@ -1719,8 +1710,6 @@ begin
MouseDownTime := GetTickCount; MouseDownTime := GetTickCount;
MouseDownWindow := Window; MouseDownWindow := Window;
MouseDownFocusWindow := 0;
MouseDownFocusStatus := mfFocusSense;
GetCursorPos(MouseDownPos); GetCursorPos(MouseDownPos);
NotifyUserInput := True; NotifyUserInput := True;
PLMsg:=@LMMouse; PLMsg:=@LMMouse;
@ -1739,8 +1728,6 @@ begin
end; end;
WM_LBUTTONUP: WM_LBUTTONUP:
begin begin
if (MouseDownWindow = Window) and (MouseDownFocusStatus = mfNone) then
MouseDownFocusStatus := mfFocusSense;
NotifyUserInput := True; NotifyUserInput := True;
PLMsg:=@LMMouse; PLMsg:=@LMMouse;
with LMMouse Do with LMMouse Do
@ -2101,12 +2088,6 @@ begin
// move focus to another application window but process event first // move focus to another application window but process event first
if (Window = Win32WidgetSet.AppHandle) then if (Window = Win32WidgetSet.AppHandle) then
PostMessage(Window, CM_ACTIVATE, 0, 0); PostMessage(Window, CM_ACTIVATE, 0, 0);
// handle feature mouse-click, setfocus, mouse-click -> double-click
if (Window <> MouseDownWindow) and (MouseDownFocusStatus <> mfNone) then
begin
MouseDownFocusStatus := mfFocusChanged;
MouseDownFocusWindow := Window;
end;
LMessage.Msg := LM_SETFOCUS; LMessage.Msg := LM_SETFOCUS;
end; end;
WM_SHOWWINDOW: WM_SHOWWINDOW:
@ -2546,11 +2527,6 @@ begin
end; end;
else else
case Msg of case Msg of
WM_LBUTTONDOWN, WM_LBUTTONUP:
begin
if MouseDownFocusStatus = mfFocusSense then
MouseDownFocusStatus := mfNone;
end;
{$ifndef RedirectDestroyMessages} {$ifndef RedirectDestroyMessages}
WM_NCDESTROY: WM_NCDESTROY:
begin begin

View File

@ -1,4 +1,4 @@
{ $Id$ } { $Id: win32int.pp 39894 2013-01-19 17:42:38Z juha $ }
{ {
/*************************************************************************** /***************************************************************************
WIN32INT.pp - Win32Interface Object WIN32INT.pp - Win32Interface Object
@ -253,8 +253,6 @@ uses
Win32Extra, LclProc, LCLMessageGlue; Win32Extra, LclProc, LCLMessageGlue;
type type
TMouseDownFocusStatus = (mfNone, mfFocusSense, mfFocusChanged);
PProcessEvent = ^TProcessEvent; PProcessEvent = ^TProcessEvent;
TProcessEvent = record TProcessEvent = record
Handle: THandle; Handle: THandle;
@ -268,8 +266,6 @@ var
MouseDownTime: dword; MouseDownTime: dword;
MouseDownPos: TPoint; MouseDownPos: TPoint;
MouseDownWindow: HWND = 0; MouseDownWindow: HWND = 0;
MouseDownFocusWindow: HWND;
MouseDownFocusStatus: TMouseDownFocusStatus = mfNone;
ComboBoxHandleSizeWindow: HWND = 0; ComboBoxHandleSizeWindow: HWND = 0;
IgnoreNextCharWindow: HWND = 0; // ignore next WM_(SYS)CHAR message IgnoreNextCharWindow: HWND = 0; // ignore next WM_(SYS)CHAR message
// set to true, if we are redirecting a WM_MOUSEWHEEL message, to prevent recursion // set to true, if we are redirecting a WM_MOUSEWHEEL message, to prevent recursion

View File

@ -1523,15 +1523,6 @@ begin
end; end;
WM_LBUTTONDOWN: WM_LBUTTONDOWN:
begin begin
// if mouse-click, focus-change, mouse-click, cursor hasn't moved:
// simulate double click, assume focus change due to first mouse-click
if (MouseDownFocusStatus = mfFocusChanged) and (MouseDownFocusWindow = Window)
and (GetTickCount - MouseDownTime <= GetDoubleClickTime)
and CheckMouseMovement then
begin
PostMessage(Window, WM_LBUTTONDBLCLK, WParam, LParam);
end;
{$ifndef win32} {$ifndef win32}
// Gesture recognition process to enable popup menus. // Gesture recognition process to enable popup menus.
if (lWinControl.PopupMenu <> nil) then if (lWinControl.PopupMenu <> nil) then
@ -1548,8 +1539,6 @@ begin
MouseDownTime := GetTickCount; MouseDownTime := GetTickCount;
MouseDownWindow := Window; MouseDownWindow := Window;
MouseDownFocusWindow := 0;
MouseDownFocusStatus := mfFocusSense;
GetCursorPos(MouseDownPos); GetCursorPos(MouseDownPos);
NotifyUserInput := True; NotifyUserInput := True;
PLMsg:=@LMMouse; PLMsg:=@LMMouse;
@ -1572,8 +1561,6 @@ begin
end; end;
WM_LBUTTONUP: WM_LBUTTONUP:
begin begin
if (MouseDownWindow = Window) and (MouseDownFocusStatus = mfNone) then
MouseDownFocusStatus := mfFocusSense;
NotifyUserInput := True; NotifyUserInput := True;
PLMsg:=@LMMouse; PLMsg:=@LMMouse;
with LMMouse Do with LMMouse Do
@ -1853,12 +1840,6 @@ begin
{$ifdef DEBUG_CARET} {$ifdef DEBUG_CARET}
DebugLn('WM_SETFOCUS received for window ', IntToHex(Window, 8)); DebugLn('WM_SETFOCUS received for window ', IntToHex(Window, 8));
{$endif} {$endif}
// handle feature mouse-click, setfocus, mouse-click -> double-click
if (Window <> MouseDownWindow) and (MouseDownFocusStatus <> mfNone) then
begin
MouseDownFocusStatus := mfFocusChanged;
MouseDownFocusWindow := Window;
end;
LMessage.Msg := LM_SETFOCUS; LMessage.Msg := LM_SETFOCUS;
if (lWinControl <> nil) and (lWinControl.FCompStyle = csEdit) then if (lWinControl <> nil) and (lWinControl.FCompStyle = csEdit) then
Windows.SendMessage(Window, EM_SETSEL, 0, -1); Windows.SendMessage(Window, EM_SETSEL, 0, -1);
@ -2203,11 +2184,6 @@ begin
else else
case Msg of case Msg of
WM_LBUTTONDOWN, WM_LBUTTONUP:
begin
if MouseDownFocusStatus = mfFocusSense then
MouseDownFocusStatus := mfNone;
end;
WM_NCDESTROY: WM_NCDESTROY:
begin begin
//roozbeh : test this.... //roozbeh : test this....

View File

@ -252,8 +252,6 @@ uses
Spin, CheckLst, LCLProc, LCLMessageGlue; Spin, CheckLst, LCLProc, LCLMessageGlue;
type type
TMouseDownFocusStatus = (mfNone, mfFocusSense, mfFocusChanged);
PProcessEvent = ^TProcessEvent; PProcessEvent = ^TProcessEvent;
TProcessEvent = record TProcessEvent = record
Handle: THandle; Handle: THandle;
@ -266,8 +264,6 @@ var
MouseDownTime: dword; MouseDownTime: dword;
MouseDownPos: TPoint; MouseDownPos: TPoint;
MouseDownWindow: HWND = 0; MouseDownWindow: HWND = 0;
MouseDownFocusWindow: HWND;
MouseDownFocusStatus: TMouseDownFocusStatus = mfNone;
ComboBoxHandleSizeWindow: HWND = 0;//just do not know the use yet ComboBoxHandleSizeWindow: HWND = 0;//just do not know the use yet
IgnoreNextCharWindow: HWND = 0; // ignore next WM_(SYS)CHAR message IgnoreNextCharWindow: HWND = 0; // ignore next WM_(SYS)CHAR message
OnClipBoardRequest: TClipboardRequestEvent = nil; OnClipBoardRequest: TClipboardRequestEvent = nil;