Recent

Author Topic: Does PopupMenu.PopupComponent work in Lazarus?  (Read 6852 times)

dkjMusic

  • Full Member
  • ***
  • Posts: 146
Does PopupMenu.PopupComponent work in Lazarus?
« on: January 01, 2011, 09:51:06 am »
First, do I have to implement myself a right-click popup menu for SynEdit to get right-click Cut,Copy,Paste,Delete functionality?

If so, I would like to use the PopupComponent property of the popup menu to determine which of three SynEdit's popped the menu. But, the following code leaves all the menu items enabled even when there is no selected text in ChecklistSynEdit when I right-click ChecklistSynEdit:

procedure TForm1.EditPopupMenuPopup(Sender: TObject);
begin
     if EditPopupMenu.PopupComponent =  ChecklistSynEdit then
        with ChecklistSynEdit do begin
             CutItem.Enabled := SelText <> '';
             CopyItem.Enabled := SelText <> '';
             DeleteItem.Enabled := SelText <> '';
             PasteItem.Enabled := Clipboard.HasFormat(CF_TEXT) ;
        end;
end;

If I remove the if EditPopupMenu.PopupComponent... check, the enable's work as expected.
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Does PopupMenu.PopupComponent work in Lazarus?
« Reply #1 on: January 01, 2011, 02:12:20 pm »
I can confirm that. The problem seems to be with the property PopupComponent.

dkjMusic

  • Full Member
  • ***
  • Posts: 146
[SOLVED]Re: Does PopupMenu.PopupComponent work in Lazarus?
« Reply #2 on: January 02, 2011, 04:52:56 pm »
It did work after all when I typecast PopupComponent as a SynEdit:

function TForm1.ActiveSynEdit(): TSynEdit;
begin
     Result := TSynEdit(EditPopupMenu.PopupComponent);
end;
« Last Edit: January 02, 2011, 04:58:43 pm by dkjMusic »
Windows 7 Ultimate/32 bit;
Lazarus 0.9.31/Rev 33300;
FPC 2.7.1/Rev 19464;
GDB 7.0.50;
(via CodeTyphon 2.30)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9904
  • Debugger - SynEdit - and more
    • wiki
Re: Does PopupMenu.PopupComponent work in Lazarus?
« Reply #3 on: April 01, 2011, 12:30:01 am »
Actually, it does not work in synedit (yet)
http://bugs.freepascal.org/view.php?id=19033

Note: synEdit does not pop the popup in the wm_popup menu event, it does it in either mouse-down or mouse-up.

this is because in SynEdit you can configure, if you want the popup in mouse down or up, and also on which mouse button, and/or with which shift/ctrl/..

 

TinyPortal © 2005-2018