Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004813 [JEDI VCL] 00 JVCL Components trivial always 2009-06-06 18:11 2012-09-10 14:15
Reporter had View Status public  
Assigned To obones
Priority normal Resolution fixed Platform
Status resolved   OS
Projection none   OS Version
ETA none Fixed in Version 3.46 Product Version 3.36
  Target Version Product Build
Summary 0004813: TJVDBGrid, TJVDBUltimGrid and mouse wheel
Description TJVDBGrid, TJVDBUltimGrid and mouse wheel:
if the user edits a value in the grid and then rotates wheel
up or down the new value will be lost.
Steps To Reproduce
Additional Information
Tags No tags attached.
Attached Files zip file icon testjvdbgridbug#4813.zip [^] (4,822 bytes) 2010-06-14 13:33
? file icon JvDBGrid_2011-06-20.pas [^] (160,095 bytes) 2011-06-20 16:38

- Relationships

-  Notes
(0015653)
nojoy (reporter)
2009-06-10 12:03

This seems to be intended behaviour, see following code snippet:

function [...].DoMouseWheel [...]
begin
  // Do not validate a record by error
  if DataLink.Active and (DataLink.DataSet.State <> dsBrowse) then
    DataLink.DataSet.Cancel;
  Result := inherited DoMouseWheel(Shift, WheelDelta, MousePos);
end;

But i doubt, that this behaviour is what a user expects. Furthermore this code is called before i am able to react on this event. A Dataset.Post in a OnMouseWheel-Function to workaround this, wont help because this would be called after DataSet.Cancel (see above).
I see three possible solutions
1) remove the Cancel-call or replace it with Post
2) make configurable what should happen
3) At least call Dataset.Cancel after the OnMouseWheel-Callbacks
I would prefer solution 1)
(0015759)
obones (administrator)
2009-07-03 17:16

Please provide the zipped sources of a sample application showing this
(0015902)
obones (administrator)
2009-08-04 09:37

Hello, any news?
(0016012)
R2D2-Master (reporter)
2009-08-24 08:56

I fixed this problem by moving the "onmousewheel" event to after the action I change this now everytime I receive a new version of jvcl. All other events happens after the action. I do the following.
In JvDBGrid.pas I change function "DomousewheelUp" and "DoMouseWheelDown".

example before:

function TJvDBGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
var
  Distance: Integer;
begin
  Result := False;
  if Assigned(OnMouseWheelUp) then
    OnMouseWheelUp(Self, Shift, MousePos, Result);
  if not Result then
  begin
    if not AcquireFocus then
      Exit;
    if Shift * KeyboardShiftStates = [ssCtrl] then
      Distance := VisibleRowCount - 1
    else
    if ssShift in Shift then
      Distance := 1
    else
      Distance := 2;
    if DataLink.Active then
      Result := DataLink.DataSet.MoveBy(-Distance) <> 0;
  end;
end;

example after:

function TJvDBGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
var
  Distance: Integer;
begin
  Result := False;
  if not Result then
  begin
    if not AcquireFocus then
      Exit;
    if Shift * KeyboardShiftStates = [ssCtrl] then
      Distance := VisibleRowCount - 1
    else
    if ssShift in Shift then
      Distance := 1
    else
      Distance := 2;
    if DataLink.Active then
      Result := DataLink.DataSet.MoveBy(-Distance) <> 0;
  end;
  if Assigned(OnMouseWheelUp) then
    OnMouseWheelUp(Self, Shift, MousePos, Result);
end;

I do the same to DoMousewheeldown.

Thanks
(0016170)
obones (administrator)
2009-09-23 17:14

I'm sorry, but how does this solve the original poster's problem?
(0016961)
obones (administrator)
2009-12-04 15:36

Can I get an answer here?
(0017461)
obones (administrator)
2010-06-07 13:56

Ah well, no answer, nothing can be done
(0017488)
obones (administrator)
2010-06-11 16:30

Reponed per request of the OP
(0017489)
nojoy (reporter)
2010-06-14 13:51

I have attached a project demonstrating the behaviour (testjvdbgridbug#4813.zip)

steps to reproduce:
-start programm
-change idx from 10 to 11
-change Code10 to xxx
-move mouse wheel

your changes are lost (canceled) and there is no possibility to modify this behaviour.
(0017490)
nojoy (reporter)
2010-06-14 15:35

Considering the post of R2D2-Master, I first thought, that his change would allow him to stop the Cancel-call in the OnMouseWheel-Event. But after looking at the source I am nearly sure, that this can not solve the problem.

The events are triggered with this ordering:
JvDbGrid.DoMouseWheel
  -> Dataset.Cancel
  -> TControl.DoMouseWheel
    -> OnMouseWheel
    -> JvDbGrid.DoMouseWheelDown //or Up
      -> OnMouseWheelDown //or Up
      -> Dataset.MoveBy(...)

So no OnMouseWheel-Event can supress the Cancel call nor can a change in DoMouseWheelDown/Up affect DoMouseWheel or Dataset.Cancel.


The DoMouseWheel-Function in TJvDbGrid only seems to be overwritten to produce this bug :). I do not know the original reason for this.
TDBGrid does not behave this way. Pressing KeyUp or PageUp does not behave this way. Therefore I think the Cancel call should be removed.
(0017815)
obones (administrator)
2010-10-08 16:07

The reason could be found in the SVN history.
Can you recommend a fix that works for all conditions?
(0017925)
nojoy (reporter)
2010-10-19 14:02

>The reason could be found in the SVN history.
I already checked that, but I could not find the reason. This was introduced by r4561 when JvDbGrid.pas was extracted from JvDbControls.pas. As JvDbControls did not contain the relevant code i assume this due to the inclusion of "JvDBGrid additions from Lionel Reynaud".

>Can you recommend a fix that works for all conditions?
My assumption is, that the code was introduced to prevent the situation that someone commits a changed record accidently by moving the mousewheel as already the original comment ("Ne pas valider un record par erreur" ) suggests. If this is true there is no fix that works for all conditions, as this is exactly the opposite of what I think should happen, namely post the record (as TDbGrid does, or PgUp does ...).

What would I recommend: Remove this "functionality" as it is non-standard. (It should be possible to get the same result -throwing away the data- by writing an OnMouseWheel-Event - which is not true for the opposite). But as this change would affect the default behaviour of TJvDbGrid (at least one person thought that this is a feature, not a bug) I would only add this fix for a big update.
(0018570)
obones (administrator)
2011-06-07 17:26

Better add a Boolean property to control that behavior
Do you feel like adding this?
(0018777)
stevegr (reporter)
2011-06-19 11:36

{*** Use a property ***}

private
  FCancelOnMouseWheel: Boolean;
...

published
  property CancelOnMouseWheel: Boolean read FCancelOnMouseWheel write FCancelOnMouseWheel default False;
...

function TJvDBGrid.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
  MousePos: TPoint): Boolean;
begin

  if FCancelOnMouseWheel then begin
    // Do not validate a record by error
   if DataLink.Active and (DataLink.DataSet.State <> dsBrowse) then
      DataLink.DataSet.Cancel;
  end;

  Result := inherited DoMouseWheel(Shift, WheelDelta, MousePos);
end;
(0018790)
stevegr (reporter)
2011-06-20 16:38

Updated code: Unit JvDBGrid_2011-06-20.pas
(0019492)
obones (administrator)
2012-02-23 10:13

Fixed in SVN since revision 13085 (2011 07 10)

- Issue History
Date Modified Username Field Change
2009-06-06 18:11 had New Issue
2009-06-08 17:27 had Issue Monitored: had
2009-06-10 12:03 nojoy Note Added: 0015653
2009-07-03 17:16 obones Note Added: 0015759
2009-07-03 17:16 obones Status new => feedback
2009-08-04 09:37 obones Note Added: 0015902
2009-08-24 08:56 R2D2-Master Note Added: 0016012
2009-08-24 09:02 R2D2-Master Issue Monitored: R2D2-Master
2009-09-23 17:14 obones Note Added: 0016170
2009-12-04 15:36 obones Note Added: 0016961
2010-06-07 13:56 obones Note Added: 0017461
2010-06-07 13:56 obones Status feedback => resolved
2010-06-07 13:56 obones Resolution open => suspended
2010-06-07 13:56 obones Assigned To => obones
2010-06-11 16:30 obones Note Added: 0017488
2010-06-11 16:30 obones Status resolved => feedback
2010-06-11 16:30 obones Resolution suspended => reopened
2010-06-14 13:33 nojoy File Added: testjvdbgridbug#4813.zip
2010-06-14 13:51 nojoy Note Added: 0017489
2010-06-14 15:35 nojoy Note Added: 0017490
2010-10-08 16:07 obones Note Added: 0017815
2010-10-19 14:02 nojoy Note Added: 0017925
2010-11-04 16:56 nojoy Issue Monitored: nojoy
2011-06-07 17:26 obones Note Added: 0018570
2011-06-07 17:26 obones Status feedback => acknowledged
2011-06-19 11:36 stevegr Note Added: 0018777
2011-06-20 16:38 stevegr Note Added: 0018790
2011-06-20 16:38 stevegr File Added: JvDBGrid_2011-06-20.pas
2012-02-23 10:13 obones Note Added: 0019492
2012-02-23 10:13 obones Status acknowledged => resolved
2012-02-23 10:13 obones Fixed in Version => Daily / SVN
2012-02-23 10:13 obones Resolution reopened => fixed
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46


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