Qt: implemented TPopupMenu.TrackButton

git-svn-id: trunk@22735 -
This commit is contained in:
zeljko 2009-11-24 08:29:58 +00:00
parent 24cabf85dd
commit d3fde8e1b7
2 changed files with 15 additions and 0 deletions

View File

@ -1085,6 +1085,7 @@ type
FAboutToHideHook: QMenu_hookH;
FActionHandle: QActionH;
FMenuItem: TMenuItem;
FTrackButton: QtMouseButtons;
protected
function CreateWidget(const APrams: TCreateParams): QWidgetH; override;
procedure DoPopupClose;
@ -1117,6 +1118,7 @@ type
procedure setShortcut(AShortcut: TShortcut);
procedure setText(const W: WideString); override;
procedure setVisible(visible: Boolean); override;
property trackButton: QtMouseButton read FTrackButton write FTrackButton;
end;
{ TQtMenuBar }
@ -8011,6 +8013,7 @@ end;
function TQtMenu.CreateWidget(const APrams: TCreateParams): QWidgetH;
begin
FTrackButton := QtNoButton;
FIcon := nil;
Result := QMenu_create();
FDeleteLater := True;
@ -8245,6 +8248,13 @@ begin
Result := True;
end;
QEventDestroy: SlotDestroy;
QEventMouseButtonPress,
QEventMouseButtonRelease:
begin
Result := (FTrackButton = QtLeftButton) and
(QMouseEvent_button(QMouseEventH(Event)) <> FTrackButton);
end;
end;
EndEventProcessing;
end;

View File

@ -414,6 +414,11 @@ begin
Point.X := X;
Point.Y := Y;
if APopupMenu.TrackButton = tbLeftButton then
TQtMenu(APopupMenu.Handle).trackButton := QtLeftButton
else
TQtMenu(APopupMenu.Handle).trackButton := QtRightButton;
TQtMenu(APopupMenu.Handle).PopUp(@Point);
end;