Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-03

Suggest LCL refactor for ShowContextMenu

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

AlexeyT

Maybe it's good to have LCL method to show context menu, w/o using Perform(LM_contextmenu,...). Name it ShowContextMenu(X, Y) - method must be main part of TControl.WMContextMenu

procedure TControl.WMContextMenu(var Message: TLMContextMenu);
var
   TempPopupMenu: TPopupMenu;
   P: TPoint;
   Handled: Boolean;
begin
   if (csDesigning in ComponentState) or (Message.Result  0) then Exit;
   P := GetMousePosFromMessage(Message.Pos);
   // X and Y = -1 when user clicks on keyboard menu button
   if P.X  -1 then
     P := ScreenToClient(P);
   Handled := False;
   DoContextPopup(P, Handled);
   if Handled then
   begin
     Message.Result := 1;
     Exit;
   end;
   TempPopupMenu := GetPopupMenu;
   if (TempPopupMenu  nil) then
   begin
     if not TempPopupMenu.AutoPopup then Exit;
     TempPopupMenu.PopupComponent := Self;
     if P.X = -1 then
       P := Point(0, 0);
     P := ClientToScreen(P);
     TempPopupMenu.Popup(P.X, P.Y);
     Message.Result := 1;
   end;
end;
so WMCOntextMenu will be some checks + getting X/Y + call to new
ShowContextMenu(X,Y) + Message.Result:=1.
Regards, Alexey

Reply by email