Recent

Author Topic: TVirtualStringTree popup menus don't work, conflicting handling of mouse clicks  (Read 4966 times)

den4b

  • New Member
  • *
  • Posts: 13
I posted a bug report #0026388: http://bugs.freepascal.org/view.php?id=26388

I'm porting a Delphi app to Lazarus and I'm completely stuck with TVirtualStringTree (VirtualTreeview). Table's popup menu and table header's popup menu don't work, breaking crucial application functionality. I'm trying to step through mouse click handling in VirtualTrees unit, but it's soo messy! :o

Any workaround or even hints would be much appreciated! Could somebody help please?

Description as in the bug report:

Quote
Popup menus assigned to TVirtualStringTree (VST) component do not work correctly and also conflict with each other. There seems to be a lot of conflicting handling of mouse clicks. The more mouse related options/features you enable the more broken behavior you get.

Drop a TVirtualStringTree (VST) component, assign a TPopupMenu to VST.PopupMenu, assign a VTHeaderPopupMenu to VST.Header.PopupMenu, add few columns to VST. Right-click on the column header to get VTHeaderPopupMenu which will have automatically populated column names. Then, left-click on any option in the popup menu to disable/enable associated column. Unfortunately, instead of disabling/enabling the column a VST.PopupMenu will appear.

In addition, in some configuration of VST options the VST.PopupMenu stops showing if the click is over the text of the items in VST, so you have to make sure to click outside of the displayed text to get context menu.

I tried on 3 different setups with same problems everywhere:
 * virtualtreeview-4.8.7-R2 @ Lazarus 1.2.2 r44758 FPC 2.6.4
 * virtualtreeview-4.8.7-R2 @ Lazarus TRUNK revision 45590 (20 June 2014)
 * virtualtreeview TRUNK revision 3221 (22 June 2014) @ Lazarus TRUNK revision 45590 (20 June 2014)

xleoa

  • Newbie
  • Posts: 1
Hi, do you found a solution?
I had the same probem and i just only found a workaround to handle this issue manually:

procedure TFormMain.VSTMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  HitInfo : THitInfo;
  hh: integer;
begin
  hh := VST.Header.Height + 1;
  if (y < hh) then exit;
  VST.GetHitTestInfoAt(X, Y, true, HitInfo);
  if (Button = mbRight) then begin
    if assigned(HitInfo.HitNode) then
      VSTRowsPopupMenu.PopUp;
  end;
end; 

procedure TFormMain.VSTHeaderMouseDown(Sender: TVTHeader; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbRight) then begin
      VSTHeaderPopupMenu.PopUp;
  end;
end;

/L


den4b

  • New Member
  • *
  • Posts: 13
It seems to have been fixed in the development code, but I couldn't give it a proper test because the development version contained a bunch of other bugs at the time.

My bug report was marked as fixed: http://bugs.freepascal.org/view.php?id=26388

I tacked it down to a SVN commit #3417 on the same date: http://sourceforge.net/p/lazarus-ccr/svn/3417/

The fix seems trivial (only 1 line of code added), but I haven't tried it.

 

TinyPortal © 2005-2018