gtk3: implemented LM_CONTEXTMENU and popup menu showing. patch by Cedric, modified by me. issue #27231

git-svn-id: trunk@47298 -
This commit is contained in:
zeljko 2015-01-04 19:19:28 +00:00
parent 4cb443b660
commit f75635d419
2 changed files with 17 additions and 2 deletions

View File

@ -2068,6 +2068,7 @@ function TGtk3Widget.GtkEventMouse(Sender: PGtkWidget; Event: PGdkEvent): Boolea
cdecl;
var
Msg: TLMMouse;
MsgPopup : TLMMouse;
MousePos: TPoint;
MButton: guint;
begin
@ -2127,7 +2128,18 @@ begin
{$ENDIF}
NotifyApplicationUserInput(LCLObject, Msg.Msg);
Event^.button.send_event := NO_PROPAGATION_TO_PARENT;
Result := DeliverMessage(Msg, True) <> 0;
Result := false;
if Msg.Msg = LM_RBUTTONDOWN then
begin
MsgPopup := Msg;
MsgPopup.Msg := LM_CONTEXTMENU;
MsgPopup.XPos := SmallInt(Round(Event^.button.x_root));
MsgPopup.YPos := SmallInt(Round(Event^.button.y_root));
Result := DeliverMessage(MsgPopup, True) <> 0;
end;
if not Result then
Result := DeliverMessage(Msg, True) <> 0;
if Event^.type_ = GDK_BUTTON_RELEASE then
begin
Msg.Msg := LM_CLICKED;

View File

@ -274,7 +274,7 @@ begin
' IsMenuItem ',dbgs(Gtk3IsWidget(MenuItem.Widget)));
{$ENDIF}
if (AMenuItem.GetParentMenu is TPopupMenu) then
if not(Assigned(AMenuItem.Parent)) and (AMenuItem.GetParentMenu is TPopupMenu) then
ParentMenuWidget := TGtk3Menu(AMenuItem.GetParentMenu.Handle).Widget
else
ParentMenuWidget := MenuItem.Widget^.get_parent;
@ -359,6 +359,9 @@ begin
else
Result := HMENU(TGtk3MenuItem.Create(AMenuItem));
if AMenuItem.Visible then
gtk_widget_show(TGtk3MenuItem(Result).Widget);
// create the menuitem widget (normal, check or radio)
(*
if AMenuItem.Caption = cLineCaption then // create separator