lcl: redo context menu message handling:

- when called by keyboard pass -1, -1 coords
  - remove child->parent loop from LCL to widgetsets (win32 and wince do this automatically, qt do it too if mouse propagation is on)
  - don't show parent context menu if child has own standard menu (like TEdit)
qt: redo mouse handling, turn on mouse propagation and mouse tracking for most of widgets, stop propagation in event filters
gtk2: implement context menu loop
widgetsets: remove LM_PRESSED, LM_RELEASED messages (LCL does not use them and they are not needed for any compatbility reasons)

git-svn-id: trunk@26637 -
This commit is contained in:
paul 2010-07-14 08:47:02 +00:00
parent 82860f9b73
commit a3dac0b6df
12 changed files with 136 additions and 292 deletions

View File

@ -1738,13 +1738,17 @@ end;
procedure TControl.WMContextMenu(var Message: TLMContextMenu);
var
TempPopupMenu: TPopupMenu;
P2: TPoint;
P: TPoint;
Handled: Boolean;
begin
if (csDesigning in ComponentState) or (Message.Result <> 0) then Exit;
P2 := SmallPointToPoint(Message.Pos);
P := SmallPointToPoint(Message.Pos);
// X and Y = -1 when user clicks on keyboard menu button
if P.X <> -1 then
P := ScreenToClient(P);
Handled := False;
DoContextPopup(P2, Handled);
DoContextPopup(P, Handled);
if Handled then
begin
Message.Result := 1;
@ -1756,10 +1760,11 @@ begin
begin
if not TempPopupMenu.AutoPopup then Exit;
TempPopupMenu.PopupComponent := Self;
P2 := ClientToScreen(P2);
TempPopupMenu.Popup(P2.X, P2.Y);
if P.X = -1 then
P := Point(0, 0);
P := ClientToScreen(P);
TempPopupMenu.Popup(P.X, P.Y);
Message.Result := 1;
Exit;
end;
end;
@ -2145,10 +2150,6 @@ end;
Mouse event handler
------------------------------------------------------------------------------}
procedure TControl.WMRButtonUp(var Message: TLMRButtonUp);
var
Control: TControl;
P: TPoint;
ContextMenuMsg: TLMContextMenu;
begin
DoBeforeMouseMessage;
if (csCaptureMouse in ControlStyle) and (mbRight in CaptureMouseButtons) then
@ -2158,31 +2159,6 @@ begin
{$ENDIF}
MouseCapture := False;
end;
// VCL like behavior. we need to have a child-parent recursion
Control := Self;
P := SmallPointToPoint(Message.Pos);
if InheritsFrom(TWinControl) then
ContextMenuMsg.hWnd := TWinControl(Self).Handle
else
if Parent <> nil then
ContextMenuMsg.hWnd := Parent.Handle
else
ContextMenuMsg.hWnd := 0;
while (Control <> nil) and (Message.Result = 0) do
begin
ContextMenuMsg.Pos := PointToSmallPoint(P);
Message.Result := Control.Perform(LM_CONTEXTMENU, TLMessage(ContextMenuMsg).wParam, TLMessage(ContextMenuMsg).lParam);
if Message.Result = 0 then
begin
with P, Control do
begin
X := X + Left;
Y := Y + Top;
end;
Control := Control.Parent;
end;
end;
//MouseUp event is independent of return values of contextmenu
DoMouseUp(Message, mbRight);
end;
@ -3544,7 +3520,7 @@ end;
{------------------------------------------------------------------------------
TControl WMMouseMove
------------------------------------------------------------------------------}
procedure TControl.WMMouseMove(Var Message: TLMMouseMove);
procedure TControl.WMMouseMove(var Message: TLMMouseMove);
begin
{$IFDEF VerboseMouseBugfix}
DebugLn(['[TControl.WMMouseMove] ',Name,':',ClassName,' ',Message.XPos,',',Message.YPos]);

View File

@ -1916,22 +1916,6 @@ begin
DeliverMessage(Data, Mess);
end;
function gtkPressedCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMessage;
begin
Result := CallBackDefaultReturn;
if (Widget=nil) then ;
{$IFDEF EventTrace}
EventTrace('pressed', data);
{$ENDIF}
Mess.msg := LM_PRESSED;
DeliverMessage(Data, Mess);
Result := CallBackDefaultReturn;
end;
function gtkEnterCB(widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMessage;
@ -2089,21 +2073,6 @@ begin
Result:= gtksize_allocateCB( Widget, @Allocation, Data);
end;
function gtkreleasedCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMEssage;
begin
Result := CallBackDefaultReturn;
if (Widget=nil) then ;
{$IFDEF EventTrace}
EventTrace('released', data);
{$ENDIF}
Mess.msg := LM_RELEASED;
DeliverMessage(Data, Mess);
end;
function gtkInsertText(widget: PGtkWidget; char : pChar;
NewTextLength : Integer; Position : pgint; data: gPointer) : GBoolean; cdecl;
var

View File

@ -176,7 +176,6 @@ function gtkMouseBtnReleaseAfter(widget: PGtkWidget; event: pgdkEventButton;
data: gPointer): GBoolean; cdecl;
function gtkclickedCB( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkPressedCB( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkEnterCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkLeaveCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtksize_allocateCB(widget: PGtkWidget; size :pGtkAllocation;
@ -185,7 +184,6 @@ function gtksize_allocate_client(widget: PGtkWidget; size :pGtkAllocation;
data: gPointer): GBoolean; cdecl;
function gtkconfigureevent( widget: PGtkWidget; event: PgdkEventConfigure;
data: gPointer): GBoolean; cdecl;
function gtkreleasedCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkInsertText(widget: PGtkWidget; char: pChar; NewTextLength:
Integer; Position: pgint; data: gPointer): GBoolean; cdecl;
function gtkSetEditable( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;

View File

@ -3570,18 +3570,6 @@ begin
ConnectSenderSignal(gCore, 'next-month', @gtkmonthchanged);
end;
LM_PRESSED:
begin
Assert(False, 'Trace:OBSOLETE: [TGtkWidgetSet.SetCallback] LM_PRESSED');
ConnectSenderSignal(gObject, 'pressed', @gtkpressedCB);
end;
LM_RELEASED:
begin
Assert(False, 'Trace:OBSOLETE: [TGtkWidgetSet.SetCallback] LM_RELEASED');
ConnectSenderSignal(gObject, 'released', @gtkreleasedCB);
end;
LM_MOUSEMOVE:
begin
{$IFDEF GTK1}

View File

@ -1378,8 +1378,7 @@ end;
Called whenever the mouse is over a widget and a mouse button is pressed.
-------------------------------------------------------------------------------}
function gtkMouseBtnPress(widget: PGtkWidget; event: pgdkEventButton;
data: gPointer) : GBoolean; cdecl;
function gtkMouseBtnPress(widget: PGtkWidget; event: pgdkEventButton; data: gPointer): GBoolean; cdecl;
procedure CheckListSelection;
var
@ -1421,10 +1420,15 @@ function gtkMouseBtnPress(widget: PGtkWidget; event: pgdkEventButton;
var
DesignOnlySignal: boolean;
AWinControl: TWinControl;
Msg: TLMContextMenu;
x, y: gint;
W: PGtkWidget;
Info: PWidgetInfo;
Old: TObject;
begin
Result := CallBackDefaultReturn;
MousePositionValid := False;
AWinControl:=TWinControl(Data);
AWinControl := TWinControl(Data);
{$IFDEF VerboseMouseBugfix}
DebugLn('');
@ -1459,12 +1463,32 @@ begin
//CaptureMouseForWidget(CaptureWidget,mctGTKIntf);
end
else
// how to skip default right click handling? LCL can tell only on mouse up
// if handling can be skiped but gtk needs on mouse down
if (Event^.button = 3) and
((AWinControl.PopupMenu <> nil) or
(TWinControlAccess(Data).OnContextPopup <> nil)) then begin
Result := True;
// if LCL process LM_CONTEXTMENU then stop the event propagation
if (Event^.button = 3) then
begin
W := Widget;
gdk_display_get_pointer(gtk_widget_get_display(Widget), nil, @x, @y, nil);
Old := nil;
while W <> nil do
begin
Info := GetWidgetInfo(W);
if (Info <> nil) and (Info^.LCLObject <> Old) then
begin
Old := Info^.LCLObject;
FillChar(Msg, SizeOf(Msg), #0);
Msg.Msg := LM_CONTEXTMENU;
Msg.hWnd := HWND(W);
Msg.XPos := x;
Msg.YPos := y;
Result := DeliverMessage(Old, Msg) <> 0;
if Result then break;
end;
// check if widget has a standard popup menu
if Assigned(GTK_WIDGET_GET_CLASS(W)^.popup_menu) then
break;
W := gtk_widget_get_parent(W);
end;
end;
end else begin
if (event^.Button=1) and
@ -1920,22 +1944,6 @@ begin
DeliverMessage(Data, Mess);
end;
function gtkPressedCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMessage;
begin
Result := CallBackDefaultReturn;
if (Widget=nil) then ;
{$IFDEF EventTrace}
EventTrace('pressed', data);
{$ENDIF}
Mess.msg := LM_PRESSED;
DeliverMessage(Data, Mess);
Result := CallBackDefaultReturn;
end;
function gtkEnterCB(widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMessage;
@ -2080,21 +2088,6 @@ begin
Result:= gtksize_allocateCB( Widget, @Allocation, Data);
end;
function gtkreleasedCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMEssage;
begin
Result := CallBackDefaultReturn;
if (Widget=nil) then ;
{$IFDEF EventTrace}
EventTrace('released', data);
{$ENDIF}
Mess.msg := LM_RELEASED;
DeliverMessage(Data, Mess);
end;
function gtkInsertText(widget: PGtkWidget; char : pChar;
NewTextLength : Integer; Position : pgint; data: gPointer) : GBoolean; cdecl;
var

View File

@ -164,7 +164,6 @@ function gtkMouseBtnReleaseAfter(widget: PGtkWidget; event: pgdkEventButton;
data: gPointer): GBoolean; cdecl;
function gtkclickedCB( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkPressedCB( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkEnterCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkLeaveCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtksize_allocateCB(widget: PGtkWidget; size :pGtkAllocation;
@ -173,7 +172,6 @@ function gtksize_allocate_client(widget: PGtkWidget; size :pGtkAllocation;
data: gPointer): GBoolean; cdecl;
function gtkconfigureevent( widget: PGtkWidget; event: PgdkEventConfigure;
data: gPointer): GBoolean; cdecl;
function gtkreleasedCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
function gtkInsertText(widget: PGtkWidget; char: pChar; NewTextLength:
Integer; Position: pgint; data: gPointer): GBoolean; cdecl;
function gtkSetEditable( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;

View File

@ -118,28 +118,15 @@ end;
function gtk2PopupMenuCB(Widget: PGtkWidget; data: gPointer): gboolean; cdecl;
var
Msg: TLMContextMenu;
x, y: gint;
begin
FillChar(Msg, SizeOf(Msg), #0);
Msg.Msg := LM_CONTEXTMENU;
Msg.hWnd := HWND(Widget); // todo: true keystate
gtk_widget_get_pointer(Widget, @x, @y);
if x > Widget^.allocation.width then
x := Widget^.allocation.width
else
if x < 0 then
x := 0;
if y > Widget^.allocation.height then
y := Widget^.allocation.height
else
if y < 0 then
y := 0;
Msg.XPos := x;
Msg.YPos := y;
// keyboard popup menu must have -1, -1 coords
Msg.XPos := -1;
Msg.YPos := -1;
Result := DeliverMessage(TComponent(data), Msg) <> 0;
end;
@ -602,18 +589,6 @@ begin
ConnectSenderSignal(gCore, 'next-month', @gtkmonthchanged);
end;
LM_PRESSED:
begin
Assert(False, 'Trace:OBSOLETE: [TGtkWidgetSet.SetCallback] LM_PRESSED');
ConnectSenderSignal(gObject, 'pressed', @gtkpressedCB);
end;
LM_RELEASED:
begin
Assert(False, 'Trace:OBSOLETE: [TGtkWidgetSet.SetCallback] LM_RELEASED');
ConnectSenderSignal(gObject, 'released', @gtkreleasedCB);
end;
LM_MOUSEMOVE:
begin
ConnectSenderSignal(gMouse, 'motion-notify-event', @GTKMotionNotify,

View File

@ -167,18 +167,18 @@ type
function SlotClose: Boolean; cdecl; virtual;
procedure SlotDestroy; cdecl;
function slotDropFiles(Sender: QObjectH; Event: QEventH): Boolean;
procedure SlotHover(Sender: QObjectH; Event: QEventH); cdecl;
function SlotHover(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
function SlotKey(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
function SlotMouse(Sender: QObjectH; Event: QEventH): Boolean; virtual; cdecl;
procedure SlotNCMouse(Sender: QObjectH; Event: QEventH); cdecl;
procedure SlotMouseEnter(Sender: QObjectH; Event: QEventH); cdecl;
procedure SlotMouseMove(Event: QEventH); cdecl;
function SlotMouseMove(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
procedure SlotMouseWheel(Sender: QObjectH; Event: QEventH); cdecl;
procedure SlotMove(Event: QEventH); cdecl;
procedure SlotPaintBg(Sender: QObjectH; Event: QEventH); cdecl;
procedure SlotPaint(Sender: QObjectH; Event: QEventH); cdecl;
procedure SlotResize(Event: QEventH); cdecl;
procedure SlotContextMenu(Sender: QObjectH; Event: QEventH); cdecl;
function SlotContextMenu(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
procedure SlotWhatsThis(Sender: QObjectH; Event: QEventH); cdecl;
procedure SlotLCLMessage(Sender: QObjectH; Event: QEventH); cdecl;
public
@ -1644,8 +1644,6 @@ begin
end;
procedure TQtWidget.InitializeWidget;
var
QtEdit: IQtEdit;
begin
// default color roles
SetDefaultColorRoles;
@ -1686,13 +1684,6 @@ begin
if (LCLObject <> nil) and not (Self is TQtMainWindow) then
setFocusPolicy(QtClickFocus);
// Set context menus to custom so LCL can better handle our popup menus
if Supports(Self, IQtEdit, QtEdit) then
begin
setContextMenuPolicy(QtCustomContextMenu);
setAttribute(QtWA_NoMousePropagation, True);
end;
if (csDesigning in LCLObject.ComponentState) and not
(Self is TQtMainWindow) and
HasPaint and
@ -2028,7 +2019,7 @@ begin
QEventHoverEnter,
QEventHoverLeave,
QEventHoverMove: SlotHover(Sender, Event);
QEventHoverMove: Result := SlotHover(Sender, Event);
QEventDrop,
QEventDragMove,
@ -2051,10 +2042,7 @@ begin
QEventMouseButtonPress,
QEventMouseButtonRelease,
QEventMouseButtonDblClick: Result := SlotMouse(Sender, Event);
QEventMouseMove:
begin
SlotMouseMove(Event);
end;
QEventMouseMove: Result := SlotMouseMove(Sender, Event);
QEventWheel:
begin
SlotMouseWheel(Sender, Event);
@ -2069,7 +2057,8 @@ begin
if FHasPaint then
SlotPaint(Sender, Event);
end;
QEventContextMenu: SlotContextMenu(Sender, Event);
QEventContextMenu:
Result := SlotContextMenu(Sender, Event);
QEventNonClientAreaMouseButtonPress:
begin
SlotNCMouse(Sender, Event);
@ -2293,17 +2282,17 @@ begin
end;
end;
procedure TQtWidget.SlotHover(Sender: QObjectH; Event: QEventH); cdecl;
function TQtWidget.SlotHover(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
var
Msg: TLMessage;
MouseMsg: TLMMouseMove absolute Msg;
MousePos: TQtPoint;
begin
if not CanSendLCLMessage then
exit;
Exit(False);
if QApplication_mouseButtons() = 0 then // in other case MouseMove will be hooked
if (QApplication_mouseButtons() = 0) and
not QWidget_hasMouseTracking(QWidgetH(Sender)) then // in other case MouseMove will be hooked
begin
FillChar(Msg, SizeOf(Msg), #0);
@ -2311,9 +2300,9 @@ begin
OffsetMousePos(@MousePos);
case QEvent_type(Event) of
QEventHoverEnter : Msg.Msg := CM_MOUSEENTER;
QEventHoverLeave : Msg.Msg := CM_MOUSELEAVE;
QEventHoverMove :
QEventHoverEnter: Msg.Msg := CM_MOUSEENTER;
QEventHoverLeave: Msg.Msg := CM_MOUSELEAVE;
QEventHoverMove:
begin
MouseMsg.Msg := LM_MOUSEMOVE;
MouseMsg.XPos := SmallInt(MousePos.X);
@ -2321,7 +2310,11 @@ begin
end;
end;
NotifyApplicationUserInput(Msg.Msg);
DeliverMessage(Msg);
Result := DeliverMessage(Msg) = 0;
if Result then
QEvent_accept(Event)
else
QEvent_ignore(Event)
end;
end;
@ -2653,9 +2646,12 @@ begin
QtMidButton: Msg.Msg := CheckMouseButtonDown(2);
end;
NotifyApplicationUserInput(Msg.Msg);
DeliverMessage(Msg);
Msg.Msg := LM_PRESSED;
DeliverMessage(Msg);
Result := DeliverMessage(Msg) = 0;
// accept the event so we have no message propagation
if Result then
QEvent_accept(Event)
else
QEvent_ignore(Event);
end;
QEventMouseButtonRelease:
begin
@ -2669,7 +2665,12 @@ begin
end;
NotifyApplicationUserInput(Msg.Msg);
DeliverMessage(Msg);
Result := DeliverMessage(Msg) = 0;
// accept the event so we have no message propagation
if Result then
QEvent_accept(Event)
else
QEvent_ignore(Event);
{ Clicking on buttons operates differently, because QEventMouseButtonRelease
is sent if you click a control, drag the mouse out of it and release, but
@ -2679,8 +2680,6 @@ begin
Msg.Msg := LM_CLICKED;
DeliverMessage(Msg);
end;
Msg.Msg := LM_RELEASED;
DeliverMessage(Msg);
end;
end;
end;
@ -2763,14 +2762,13 @@ end;
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TQtWidget.SlotMouseMove(Event: QEventH); cdecl;
function TQtWidget.SlotMouseMove(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
var
Msg: TLMMouseMove;
MousePos: TQtPoint;
begin
if not CanSendLCLMessage then
exit;
Exit(False);
FillChar(Msg, SizeOf(Msg), #0);
MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
@ -2785,7 +2783,12 @@ begin
Msg.Msg := LM_MOUSEMOVE;
NotifyApplicationUserInput(Msg.Msg);
DeliverMessage(Msg);
// stop event propagation
Result := DeliverMessage(Msg) = 0;
if Result then
QEvent_accept(Event)
else
QEvent_ignore(Event);
end;
{------------------------------------------------------------------------------
@ -3043,12 +3046,11 @@ begin
DeliverMessage(Msg);
end;
procedure TQtWidget.SlotContextMenu(Sender: QObjectH; Event: QEventH); cdecl;
function TQtWidget.SlotContextMenu(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
var
Msg: TLMContextMenu;
MousePos: TQtPoint;
QtEdit: IQtEdit;
AResult: LResult;
procedure SendMouseReleaseEventToSelf;
var
@ -3067,8 +3069,32 @@ var
begin
if not CanSendLCLMessage then
exit;
Exit;
FillChar(Msg, SizeOf(Msg), #0);
MousePos := QContextMenuEvent_globalPos(QContextMenuEventH(Event))^;
Msg.Msg := LM_CONTEXTMENU;
Msg.hWnd := HWND(Self);
if QContextMenuEvent_reason(QContextMenuEventH(Event)) = QContextMenuEventKeyboard then
begin
Msg.XPos := -1;
Msg.YPos := -1;
end
else
begin
Msg.XPos := SmallInt(MousePos.X);
Msg.YPos := SmallInt(MousePos.Y);
end;
Result := DeliverMessage(Msg) <> 0;
if Result then
QEvent_accept(Event)
else
QEvent_ignore(Event);
if Result and (csDesigning in LCLObject.ComponentState) then
SendMouseReleaseEventToSelf;
{
if Supports(Self, IQtEdit, QtEdit) then
begin
if Assigned(LCLObject.PopupMenu) then
@ -3080,22 +3106,9 @@ begin
{revert to default if widget supports defaultcontextmenu }
if getContextMenuPolicy <> QtDefaultContextMenu then
setContextMenuPolicy(QtDefaultContextMenu);
exit;
Exit;
end;
end;
FillChar(Msg, SizeOf(Msg), #0);
MousePos := QContextMenuEvent_pos(QContextMenuEventH(Event))^;
OffsetMousePos(@MousePos);
Msg.Msg := LM_CONTEXTMENU;
Msg.hWnd := HWND(Self);
Msg.XPos := SmallInt(MousePos.X);
Msg.YPos := SmallInt(MousePos.Y);
AResult := DeliverMessage(Msg);
if (AResult = 1) and (csDesigning in LCLObject.ComponentState) then
SendMouseReleaseEventToSelf;
end;}
end;
procedure TQtWidget.SlotWhatsThis(Sender: QObjectH; Event: QEventH); cdecl;
@ -4474,8 +4487,9 @@ begin
MenuBar := TQtMenuBar.Create(Result);
{$endif}
if (Application.MainForm <> nil) and (Application.MainForm.FormStyle = fsMDIForm)
and not (csDesigning in LCLObject.ComponentState) then
if (Application.MainForm <> nil) and
(Application.MainForm.FormStyle = fsMDIForm) and
not (csDesigning in LCLObject.ComponentState) then
begin
FCentralWidget := QWidget_create(Result);
MDIAreaHandle := QMdiArea_create(Result);
@ -4494,8 +4508,11 @@ begin
end;
if FCentralWidget <> nil then
begin
QMainWindow_setCentralWidget(QMainWindowH(Result), FCentralWidget);
QWidget_setMouseTracking(FCentralWidget, True);
end;
if not (csDesigning in LCLObject.ComponentState) then
QMainWindow_setDockOptions(QMainWindowH(Result), QMainWindowAnimatedDocks);
end
@ -4518,12 +4535,13 @@ begin
else
begin
if (TCustomForm(LCLObject).FormStyle = fsSplash) and
not (csDesigning in LCLObject.ComponentState) then
not (csDesigning in LCLObject.ComponentState) then
Result := QWidget_create(nil, QtSplashScreen)
else
Result := QWidget_create(nil, QtWindow);
QWidget_setAttribute(Result, QtWA_Hover);
QWidget_setMouseTracking(Result, True);
end;
// Main menu bar
@ -4534,7 +4552,8 @@ begin
{$endif}
FCentralWidget := QWidget_create(Result);
QWidget_setMouseTracking(FCentralWidget, True);
LayoutWidget := QBoxLayout_create(QBoxLayoutTopToBottom, Result);
QBoxLayout_setSpacing(LayoutWidget, 0);
@ -4549,8 +4568,6 @@ begin
QWidget_setLayout(Result, QLayoutH(LayoutWidget));
QWidget_setAttribute(Result, QtWA_DeleteOnClose);
end;
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
procedure TQtMainWindow.ChangeParent(NewParent: QWidgetH);
@ -4955,7 +4972,6 @@ begin
else
Parent := nil;
Result := QLabel_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
function TQtStaticText.CanPaintBackground: Boolean;
@ -5290,7 +5306,6 @@ begin
Result := QFrame_create(Parent);
if (QtVersionMajor = 4) and (QtVersionMinor < 6) then
QWidget_setAutoFillBackground(Result, True);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
procedure TQtFrame.setFocusPolicy(const APolicy: QtFocusPolicy);
@ -5350,7 +5365,6 @@ begin
else
Parent := nil;
Result := QFrame_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
function TQtAbstractSlider.CreateWidget(const AParams: TCreateParams): QWidgetH;
@ -6465,8 +6479,7 @@ begin
inherited DetachEvents;
end;
function TQtTextEdit.viewportEventFilter(Sender: QObjectH; Event: QEventH
): Boolean; cdecl;
function TQtTextEdit.viewportEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin
Result := False;
QEvent_accept(Event);
@ -6474,8 +6487,8 @@ begin
QEventContextMenu: SlotContextMenu(Sender, Event);
QEventMouseButtonPress,
QEventMouseButtonRelease,
QEventMouseButtonDblClick: SlotMouse(Sender, Event);
QEventMouseMove: SlotMouseMove(Event);
QEventMouseButtonDblClick: Result := SlotMouse(Sender, Event);
QEventMouseMove: Result := SlotMouseMove(Sender, Event);
end;
end;
@ -8152,7 +8165,6 @@ begin
else
Parent := nil;
Result := QListWidget_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
procedure TQtListWidget.OwnerDataNeeded(ARect: TRect);
@ -8904,7 +8916,6 @@ begin
else
Parent := nil;
Result := QListWidget_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
function TQtCheckListBox.EventFilter(Sender: QObjectH; Event: QEventH
@ -9241,7 +9252,6 @@ begin
Parent := nil;
Result := QTreeWidget_create(Parent);
FHeader := nil;
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
{------------------------------------------------------------------------------
@ -10596,7 +10606,6 @@ begin
else
Parent := nil;
Result := QProgressBar_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation, True);
end;
procedure TQtProgressBar.AttachEvents;
@ -10680,7 +10689,6 @@ begin
else
Parent := nil;
Result := QLabel_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
procedure TQtStatusBarPanel.DrawItem(Sender: QObjectH; Event: QEventH);
@ -11179,7 +11187,6 @@ begin
end else
QWidget_setAutoFillBackground(Result, False);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
QWidget_setAttribute(Result, QtWA_InputMethodEnabled);
end;
@ -11890,7 +11897,6 @@ begin
Result := QWidget_create(Parent);
if (QtVersionMajor = 4) and (QtVersionMinor < 6) then
QWidget_setAutoFillBackground(Result, True);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
function TQtPage.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
@ -12471,7 +12477,6 @@ begin
else
Parent := nil;
Result := QGraphicsView_create(Parent);
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
end;
{ TQtDesignWidget }

View File

@ -1963,22 +1963,15 @@ begin
end;
WM_CONTEXTMENU:
begin
WinProcess := false;
WinProcess := False;
NotifyUserInput := True;
PLMsg:=@LMContextMenu;
PLMsg := @LMContextMenu;
with LMContextMenu do
begin
Msg := LM_CONTEXTMENU;
XPos := GET_X_LPARAM(LParam);
YPos := GET_Y_LPARAM(LParam);
hWnd := Window;
//Only keyboard triggered contextmenu (Shift-F10) should be sent to LCL
//but calling default handler is necessary. This schema avoids parent recursion
//and also keeps default popupmenu (TMemo)
if XPos = -1 then
Pos := GetClientCursorPos(Window)
else
lWinControl := nil; // make sure no message is sent to the LCL
Result := 0;
end;
end;

View File

@ -196,6 +196,7 @@ Var
LMKey: TLMKey; // used by WM_KEYDOWN WM_KEYUP
LMChar: TLMChar; // used by WM_CHAR
LMMouse: TLMMouse; // used by WM_LBUTTONDBLCLK
LMContextMenu: TLMContextMenu;
LMMouseMove: TLMMouseMove; // used by WM_MOUSEMOVE
LMMouseEvent: TLMMouseEvent; // used by WM_MOUSEWHEEL
LMMove: TLMMove; // used by WM_MOVE
@ -1790,26 +1791,15 @@ begin
begin
WinProcess := false;
NotifyUserInput := True;
PLMsg:=@LMMouse;
with LMMouse Do
PLMsg := @LMContextMenu;
with LMContextMenu do
begin
Msg := LM_RBUTTONUP;
Msg := LM_CONTEXTMENU;
XPos := GET_X_LPARAM(LParam);
YPos := GET_Y_LPARAM(LParam);
hWnd := Window;
Result := 0;
end;
if (LMMouse.XPos<>-1) and (LMMouse.YPos<>-1) then
begin
P := SmallPointToPoint(LMMouse.Pos);
Windows.ScreenToClient(Window, Windows.POINT(P));
LMMouse.Pos := PointToSmallPoint(P);
end
else
begin
LMMouse.XPos := 0;
LMMouse.YPos := 0; {TODO : Fix that in future because popup menu should
appear near selected element of control}
end;
end;
WM_SETCURSOR:
begin

View File

@ -51,8 +51,6 @@ function LCLSendSelectionChangedMsg(const Target: TControl): PtrInt;
function LCLSendDestroyMsg(const Target: TControl): PtrInt;
function LCLSendChangedMsg(const Target: TControl; ItemIndex: WPARAM = 0): PtrInt;
function LCLSendClickedMsg(const Target: TControl): PtrInt;
function LCLSendPressedMsg(const Target: TControl): PtrInt;
function LCLSendReleasedMsg(const Target: TControl): PtrInt;
function LCLSendMouseEnterMsg(const Target: TControl): PtrInt;
function LCLSendMouseLeaveMsg(const Target: TControl): PtrInt;
function LCLSendSetEditableMsg(const Target: TControl): PtrInt;
@ -522,42 +520,6 @@ begin
Result := SendSimpleMessage(Target, LM_CLICKED);
end;
{******************************************************************************
* *
* LCLSendPressedMsg *
* *
* Returns : 0 to accept the message, non-zero to reject the message *
* *
* Params *
* *
* Target : The Control that will recieve the message LM_PRESSED *
* *
* Not used by the LCL *
* *
******************************************************************************}
function LCLSendPressedMsg(const Target: TControl): PtrInt;
begin
Result := SendSimpleMessage(Target, LM_PRESSED);
end;
{******************************************************************************
* *
* LCLSendReleasedMsg *
* *
* Returns : 0 to accept the message, non-zero to reject the message *
* *
* Params *
* *
* Target : The Control that will recieve the message LM_RELEASED *
* *
* Not used by the LCL *
* *
******************************************************************************}
function LCLSendReleasedMsg(const Target: TControl): PtrInt;
begin
Result := SendSimpleMessage(Target, LM_RELEASED);
end;
{******************************************************************************
* *
* LCLSendMouseEnterMsg *

View File

@ -56,7 +56,6 @@ const
LM_CHANGED = LM_LCL + 05;
LM_FOCUS = LM_LCL + 06;
LM_CLICKED = LM_LCL + 07;
LM_PRESSED = LM_LCL + 08;
LM_RELEASED = LM_LCL + 09;
LM_ENTER = LM_LCL + 11;
LM_LEAVE = LM_LCL + 12;
@ -934,8 +933,6 @@ begin
LM_CHANGED :Result:='LM_CHANGED';
LM_FOCUS :Result:='LM_FOCUS';
LM_CLICKED :Result:='LM_CLICKED';
LM_PRESSED :Result:='LM_PRESSED';
LM_RELEASED :Result:='LM_RELEASED';
LM_ENTER :Result:='LM_ENTER';
LM_LEAVE :Result:='LM_LEAVE';
LM_CHECKRESIZE :Result:='LM_CHECKRESIZE';