Jump to content


Photo

Strange behaviour with SelectRow and Modal forms


  • Please log in to reply
25 replies to this topic

#1 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 27 September 2006 - 09:33 PM

Hallo again...

I am having a strange problem with the SelectedRow and Modal forms.

I need to change the SelectedRow from a modal form that is shown when the user double-clicks on the grid. If I create the modal form manually, change the selected row of the grid from the modal form and then close the modal form again, everything works fine. But if I do the same thing in the grid's double-click event the selectedrow gets reset to it's original value when the modal form is closed.

In the attached demo, select the second row (row 1) and click on the "Show Form" button. A message will show the selectedrow (1) and will then show the form. Now click on the "Next" button and you will see the indicator changing position to the next row in the grid. Close the modal form and another messge will show the new selectedrow (4 or whatever) and the form will close - everything fine.

Now do the same thing by double-clicking on the grid. When the modal form closes you will see the message (row 4) but then the selectedrow on the grid gets reset back to row 1.

I think this ties in to my previous issue with double-clicking the header and showing a modal form. It is like execution is passed to the modal form before the grid gets a chance to "finish what it's doing".

This is a major issue that needs to be resolved. Some of the grid's internal code is definately not being executed after a double-click.

Please help.

Regards,

Deon

Attached Files



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 27 September 2006 - 10:38 PM

Hi Denvn,

I think that I know why this happen. This have something with a double click event, because mouse up part of dbl-click occur again after modal form is closed.

This will be quite sensible problem, I will need to look on it more.

I suggest for first time that you remember SelectedRow in OnClose event of second form and then return it again in OnDoubleClick event

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 28 September 2006 - 07:30 AM

I will try a workaround for now, but please try to get this fixed.

You can also see this happening if you double-click on a column header and show a MessageDlg. After the message is closed, and you click on a different column header to sort the column, there is no response. You have to click the header twice before it works. This is obviously also related to the header never getting the MouseUp.

While you are looking at this, I really think you should also look at providing a seperate event for double-clicks on the header. Currenty I have my own code in the double-click event that check if the mouse is in the header area or in the body area, so I can ignore double-clicks on the header. Double-clicking on the header should just change the sort order (same as Outlook 2007).

It is only in rare cases that people would want to use the double-click event for the header, and even then they would not want the event to be the same as if someone double-clicked on the body of the grid.

Once you get the double-click event working, I suggest you add a seperate event for OnHeaderDblClick.

Regards,

Deon

#4 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 23 October 2006 - 03:14 PM

Hi Boki

This issue is still unresolved. As you can see from the screenshot, the header is still not getting the MouseUp event and is not being repainted.

As I said earlier, I believe that the grid's OnDblClick should not respond to double-clicks on the header (or there should at least be a seperate event like OnHeaderDblClick). In Microsoft grids (like Outlook) a double-click on the header is treated like a single click, and just changes the sort order.

Regardless of the header, you should still be able to double-click anywhere on the grid and open a modal form. I don't know what the other people do, but to me it seems that double-clicking on a row to open a detail window would be quite a common thing. Currently however, this causes strange behaviour that I can not pass on to my clients.

Please look at this whole double-clicking issue when you have time.

Thanks

Deon

Attached Files

  • Attached File  Demo.jpg   37.9KB   58 downloads


#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 23 October 2006 - 07:13 PM

Hello Deon,

I will most probably add OnHeaderDblClick, but still have no idea what is a problem with problem you have reported.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 24 October 2006 - 10:39 AM

Hi Boki

I have attached a demo with instructions on how to recreate the problem.

Hopefully this will make it clearer.

Thanks

Deon

Attached Files

  • Attached File  Demo.zip   275.01KB   22 downloads


#7 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 25 October 2006 - 01:35 PM

Hi Boki

Have you looked at the demo yet? Do you understand what I mean now?

Let me know

regards,

Deon

#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 25 October 2006 - 02:18 PM

Hello Deon,

I know whre it a problem, but still have time to solve it.

When you DoubleClick on row and open Modal Form, there is one MouseUp still remaining to be triggered on Grid and this is why this happen. It is quite tricky and I need time to solve it.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 25 October 2006 - 04:39 PM

OK. I just wanted to make sure that you are aware of this.

I understand that this is not a quick fix, but please don't let it slip to the bottom of the pile smile.gif

Thanks

Deon

#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 25 October 2006 - 05:15 PM

Hello Deon,

I will try to fix it as soon as possible, but it look very tricky sad.gif

I really hope that I will soon enable my bug tracker and all bugs will be easily located then.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 25 October 2006 - 06:53 PM

Hi,

I think it may be related to that (as I remember) a doubleclick always incorporates a single click too. So it may be because you get to much instead of lose something.

Btw the following code discriminates between header & table:

CODE
function ClickedOnTable(const Control: TNextGrid): Boolean;
begin
  Result := not (PtInRect(Control.GetHeaderRect, Control.ScreenToClient(Mouse.CursorPos)));
end;


and even better (on an existing row):

CODE
function ClickedOnTableRow(const Control: TNextGrid): Boolean;
var
  mp                            : TPoint;
  ndx                           : Integer;
begin
  mp := Control.ScreenToClient(Mouse.CursorPos);
  ndx := Control.GetRowAtPos(mp.X, mp.Y);
  Result := not (PtInRect(Control.GetHeaderRect, mp)) and
    (ndx > -1) and
    (ndx < Control.RowCount);
end;

G.W. van der Vegt

#12 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 25 October 2006 - 09:58 PM

Hi Wim

The code would work fine to seperate header clicks from body (or row) clicks, it's just a pain to add it every time (but I will do so for now - thanks).

You are correct that double-clicks include a single click (double-clicks fires on the second mousedown), but the problem is more complicated than that. The grid uses the mousedown event to change the state of header cells (maybe you want to drag the header?), but since the double-click also fires on the second mousedown and then immediately creates the modal form, the grid never gets the second mousup to update the grid's state. It now thinks that the header is still in the "clicked" state, which is why is doesn't respond the subsequent clicks.

To complicate matters, I think (and I am guessing here) that the headers also use mousemove/enter/exit to set the "hot" states, so the header also doesn't know that the mouse has left it's client area, and stays "hot".

All of this would have been a lot simpler if the double-click just fired on the second MouseUP instead of the MouseDown. Oh well.....

Thanks again

Deon

#13 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 18 November 2006 - 11:07 AM

Hi Boki

The OnHeaderDblClick that you added in the latest version doesn't really work. The normal DblClick event is still triggered if you double-click on the header. This means that is you have code in OnDblClick, and you also have code in OnHeaderDblClick, BOTH events will fire when you click on the header.

To make matters worse, the OnHeaderDblClick now also has the same problem as the normal DblClick (it doesn't get the second MouseUp if you show a modal form in the OnHeaderDblClick event).

You can fix both these problems like this:

Add a new property to NxCustomGrid called FMouseUpDone.

CODE
  TNxCustomGrid = class(TNxCustomGridControl)
  private
    FColumnDragBox: TColumnDragBox;
    FDownDragArrow: TDragArrow;
    FDragDropColumn: TNxCustomColumn;
    FFooterHintColumn: TNxCustomColumn;
    FHeaderHintColumn: TNxCustomColumn;
    FLeftResizingGuide: Integer;
    FMouseDownColumn: TNxCustomColumn;
    FMouseDownPoint: TPoint;
    FMouseDownRow: Integer;
    FMoveRow: Integer;
//dvn
FMouseUpDone: Boolean;
    FOldHeight: Integer;
    FOldRowPosition: Integer;


Remove all the code from the DblClick procedure.

CODE
procedure TNxCustomGrid.DblClick;
var
  CursorPoint: TPoint;
  Column: TNxCustomColumn;
begin
//dvn
{
  inherited;
  GetCursorPos(CursorPoint);
  CursorPoint := ScreenToClient(CursorPoint);
  if PtInRect(GetHeaderRect, CursorPoint) then
  begin
    Column := GetColumnAtPos(CursorPoint);
    if Assigned(Column) then DoHeaderDblClick(Column.Index);
  end;
  }
end;


Change the MouseDown procedure as follows:

CODE
begin
  inherited;
    FMouseDownPoint := Point(X, Y);

//dvn new
FMouseUpDone := False;

  if ssDouble in Shift then Include(FGridState, gtDoubleClicking);

  if not(csDesigning in ComponentState) and (GetParentForm(Self).Active)
    and Visible and Enabled then SetFocus;

    if Columns.Count = 0 then Exit;

  case Button of
    mbLeft, mbRight:
    begin
      if (Button = mbRight) and (gtMultiSelect in GridState) then Exit;
      if (goHeader in Options) and  PtInRect(GetHeaderRect, Point(X, Y)) then
      begin
            FSizeProgressColumn := GetColumnSizeGripAtPos(X, Y);
      end;
          if Assigned(FSizeProgressColumn) then { resizing }
          begin
            with Canvas, FSizeProgressColumn do
            begin
          if ssDouble in Shift then
          begin
            BestFitColumn(FSizeProgressColumn.Index);
            FSizeProgressColumn := nil;
            Exit;
          end;
          Include(FGridState, gtColumnResizing);
              FSizeDelta := 0;
          RealLeft := Left;
          if FSizeProgressColumn.Position >= FixedCols then Dec(RealLeft, HorzScrollBar.Position);

          if Index = 0 then FLeftResizingGuide := RealLeft else FLeftResizingGuide := RealLeft - 1;
          FRightResizingGuide := RealLeft + Width - 1;

          Pen.Mode := pmNot;
          Polyline([Point(FLeftResizingGuide, 0), Point(FLeftResizingGuide, ClientHeight)]);
          Polyline([Point(FRightResizingGuide, 0), Point(FRightResizingGuide, ClientHeight)]);
          Pen.Mode := pmCopy;
            end;
          end else
          begin
            case GetGridArea(Point(X, Y)) of
              gaBody: BodyMouseDown;
              gaHeader: ClickOnHeader;
          gaIndicator: IndicatorMouseDown;
              gaInput: ClickOnInput;
              gaFooter: ClickOnFooter;
          else  begin
                  ApplyEditing;
                  EndEditing;
                end;
            end;
        if gtIndicatorMouseDown in GridState then BodyMouseDown;

        //dvn new start
        if gtDoubleClicking in FGridState then
          begin
            //call mouseup now so we don't miss it if DblClick shows a modal form
            MouseUp(Button, Shift, X, Y);
            FMouseUpDone := True;
            //check if mouse in header
            if PtInRect(GetHeaderRect, FMouseDownPoint) then
              begin
                Column := GetColumnAtPos(FMouseDownPoint);
                if Assigned(Column) then
                  begin
                    DoHeaderDblClick(Column.Index);
                    RefreshColumn(Column,gaHeader);
                  end;
              end
            else
              inherited DblClick;
          end;
        //dvn new end

          end; { else }
    end; { mbLeft, mbRight }
  end; { case }
end;


Change the MouseUp procedure as follows:

CODE
begin
  inherited;

//dvn new
if FMouseUpDone then
  Exit;

  FDownColumn := FMouseDownColumn;
  FMouseDownColumn := nil;
  FMouseDownPoint := Point(-1, -1);
  if gtRowMoving in GridState then
  begin
    NearestRow := GetNearestRow(FMouseDownRow, X, Y);
    if FMouseDownRow < NearestRow then Dec(NearestRow);
    if CanMoveRow(FMouseDownRow, NearestRow) then

etc, etc, ..............


Now the grid will always get the second MouseUp after a DblClick. The gridstate will be normal and all event (like column sorting etc.) will work fine. The "real" MouseUp when the mouse button is released for the second time (after DblClick) will be ignored, because MouseUp has laready been called.

Also, the DblClick will only be called for double-clicks on the grid, and the OnHeaderDblClick will only be called for double-clicks on the header.

Thanks

Deon

#14 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 November 2006 - 02:34 AM

Hello Deon,

Thank you, I will test it and if all is fine I will add it.

I was want that OnHeaderDblClick occur when OnDblClick similar to OnClick and OnHeaderClick.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#15 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 07 December 2006 - 08:52 AM

V3.9.6: still not fixed

#16 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 29 January 2007 - 08:14 PM

This issue is still unresolved on V3.9.7. I can't believe no-one else has a problem with this.

Boki.

Please let me know if you are planning to do anything about this. If you are not, I will fix it myself, but then you must please update the history.txt file when you change anything in the MouseDdown and MouseUp events so that I can check if it breaks my own code.

Deon

#17 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 29 January 2007 - 08:35 PM

To illustrate my previous point:

I have attached a screenshot of a grid with 10 columns. If you show anything modal (a message, a details form, an inut query ... anything) in the DblClick event, the grid will NOT get the second MouseUp.

In the attached screenshot, columns 1, 3, 5 and 9 are all "hot" and column 7 is only partially repainted. The selected cell is in column 6 where I last clicked the mouse.

How can 5 columns be "hot" at the same time, when the mouse is NOWHERE NEAR THEM ??

What must I tell my users? - "Oh.... yes we know about that. Just wave your mouse around over the columns until they look better."

This is a real problem - I'm not just being full of shit.

Deon

Attached Files

  • Attached File  Grid.jpg   19.87KB   15 downloads


#18 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 01 February 2007 - 03:10 PM

Hi Boki

Are you ignoring me now?

#19 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 01 February 2007 - 06:19 PM

Hello Deonvn,

I didn't see this message yet, please be patient I am doing my best. Every component and program have bugs. Someone want new and new features, someone want that every possible bug is fixed, I am only a man.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#20 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 01 February 2007 - 10:04 PM

Hi Boki

I understand, and I do not expect that every little thing is fixed immediately. But this is quite a serious problem and it has been 3 months since I reported it. I don't want to post a message every day whining about the same thing, so I wait patiently and believe that my issue has been given a certain priority and that you will get to it in your own time, when it is "my turn".

I gave you a solution for this problem two months ago. I know it's not the best solution, but it is the simplest solution I could find without changing too much of your code, and it works. You said you would check it out and add it if all is Ok (see you post around 20 November). So again I wait patiently for two months and watch the forum. I see indents being added to the lists in combo boxes, votes on multi-select in the DBGrid, new methods for sorting by multiple columns etc. etc. What I don't see is any attention begin given to existing problems (in particular mine). These other issues are not things that are "broken", the are new feature requests. In my opinion, the things that make the component unusable should be addressed before adding things that simply enhance features that already work.

My last post about this issue was when V3.9.6 was released (60 days ago?) so I really don't think I have been nagging you unneccessarily about this. You make it sound like I am expecting miracles from you, but all I expect is that valid issues get the attention they deserve. I really don't think that is too much to ask.

Regards,

Deon




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users