Difference Between PopupMenuItem Click and MouseOver

When a menu item has a secondary menu, hovering the mouse expands the submenu; it triggers a click event.

Is there any difference between this click event and if the user actually clicks?

I use TPopupMenu as a cxButton dropdown property.

EDIT Delphi 2007

+3
source share
3 answers

Not sure if this will work with D2007; this happens in D7. Can you try the following?

type
  THackPopupList = class(TPopupList)
  private
    FActuallyClicked: Boolean;
  protected
    procedure WndProc(var Message: TMessage); override;
  public
    property ActuallyClicked: Boolean read FActuallyClicked;
  end;

{ THackPopupList }

procedure THackPopupList.WndProc(var Message: TMessage);
begin
  FActuallyClicked := Message.Msg = WM_COMMAND;
  inherited WndProc(Message);
end;

{ TForm1 }

procedure TForm1.MenuFileOpenClick(Sender: TObject);
var 
  ActuallyClicked: Boolean;
begin
  ActuallyClicked := THackPopupList(PopupList).ActuallyClicked;
  ...
end;

initialization
  PopupList.Free;
  PopupList := THackPopupList.Create;

end.

Explanation: OnClick caused by a hang is triggered by WM_INITMENUPOPUP, but this click, triggered by a mouse click, is triggered by this WM_COMMAND.

, Menus.pas . , Delphi, , .

0

, . , OnClick.
Delphi 2009.

0

, MenuItem , OnClick . , :

procedure TForm1.MenuFileOpenClick(Sender: TObject);
var
  ActuallyClicked: Boolean;
begin
  ActuallyCLicked := TMenuItem(Sender).Count = 0;
end;

:

procedure TForm1.FileOpenExecute(Sender: TObject);
var
  ActuallyClicked: Boolean;
begin
  if Sender is TBasicAction then
    Sender := TBasicAction(Sender).ActionComponent;
  ActuallyCLicked := TMenuItem(Sender).Count = 0;
end;
0

All Articles