Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006474 [JEDI VCL] 00 JVCL Components major always 2015-11-30 17:08 2016-08-04 19:37
Reporter RalfNegt View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version 3.48
Summary 0006474: JvDBGrid OnMouseDown won't be called
Description Actually i cannot start a drag action with an OnMouseDown event handler.

Have a look at the method "TJvDBGrid.MouseDown" below and
especially the flag "InheritedCalled".
There are three conditions setting the flag.
The event OnMouseDown will only be called if the flag isn't set.

When i assign an event handler i want it to be called.
But here the component itself decides whether or not to do so.
Please remove the flag "InheritedCalled".
By the way the variable "MouseDownEvent" is unnecessary.
It can be replace by "OnMouseDown".

procedure TJvDBGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  MouseDownEvent: TMouseEvent;
  InheritedCalled: Boolean;
      InheritedCalled := False;
          if dgIndicator in Options then
            inherited MouseDown(Button, Shift, 1, Y);
            InheritedCalled := True;
            if (dgRowSelect in Options) and (Cell.Y >= TitleOffset) then
              // Why do we always have to work around the VCL. If we use the original X the
              // Grid will scroll back to the first column. But if we don't use the original X
              // and goRowSizing is enabled, the user can start resizing rows in the wild.
              WasRowResizing := goRowSizing in TCustomGridAccess(Self).Options;
                // Disable goRowSizing without all the code that SetOptions executes.
                TGridOptions(Pointer(@TCustomGridAccess(Self).Options)^) := TCustomGridAccess(Self).Options - [goRowSizing];
                inherited MouseDown(Button, Shift, 1, Y);
                InheritedCalled := True;
                if WasRowResizing then
                  TGridOptions(Pointer(@TCustomGridAccess(Self).Options)^) := TCustomGridAccess(Self).Options + [goRowSizing];
              inherited MouseDown(Button, Shift, X, Y);
              InheritedCalled := True;
      MouseDownEvent := OnMouseDown;
      if Assigned(MouseDownEvent) and not InheritedCalled then
        MouseDownEvent(Self, Button, Shift, X, Y);
Additional Information
Tags No tags attached.
Attached Files zip file icon [^] (1,702 bytes) 2016-04-12 11:03

- Relationships

-  Notes
dougwoodrow (reporter)
2016-04-11 11:37

This appears to have been introduced by an attempt to fix a situation with OnMouseDown being called twice.

see commit by obones Dec 16 2013 "Mantis 5915: Do not call OnMouseDown twice" [^]
dougwoodrow (reporter)
2016-04-11 12:09

This bug results in the OnMouseDown event not being called when the mouse is over a data record, it is called when the mouse is over the title buttons or outside the data records.
dougwoodrow (reporter)
2016-04-12 11:07

I've attached a sample Delphi 7 application (copied from Mantis 5915) to demonstrate the problem.

Note that with RalfNegt's proposed solution the TJvUltimGrid still has problems, but TJvDBGrid seems ok. [^]
dougwoodrow (reporter)
2016-04-12 11:30

(Sorry, please remove mad* from Project1.dpr).

Note also this problem is still present in JVCL version 3.49.
AHUser (developer)
2016-08-04 19:37

Fixed in master branch.

OnMouseDown is now called even if there was a call to "inherited MouseDown" that didn't call "TControl.MouseDown".

I also added a OnBeforeMouseDown and OnAfterMouseDown event, so you also get notified if the user clicks on a header cell.

- Issue History
Date Modified Username Field Change
2015-11-30 17:08 RalfNegt New Issue
2016-04-11 11:31 dougwoodrow Issue Monitored: dougwoodrow
2016-04-11 11:37 dougwoodrow Note Added: 0021283
2016-04-11 12:09 dougwoodrow Note Added: 0021284
2016-04-12 11:03 dougwoodrow File Added:
2016-04-12 11:08 dougwoodrow Note Added: 0021285
2016-04-12 11:30 dougwoodrow Note Added: 0021286
2016-08-04 19:37 AHUser Note Added: 0021328
2016-08-04 19:37 AHUser Status new => resolved
2016-08-04 19:37 AHUser Fixed in Version => Daily / GIT
2016-08-04 19:37 AHUser Resolution open => fixed
2016-08-04 19:37 AHUser Assigned To => AHUser

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker