Lazarus

Programming => Widgetset => Carbon => Topic started by: xinyiman on July 02, 2018, 02:51:32 pm

Title: (SOLVED) Merge cells example bug?!
Post by: xinyiman on July 02, 2018, 02:51:32 pm
Hi guys, I wanted to report a non-working example released with lazarus. This is the example to merge cells in TStringGrid. I have also attached the example, but if you compile and run mac (carbon) and double-click on a blank cell, it generates an exception in the DoEditorShow procedure. Does anyone know how to solve?
Title: Re: Merge cells example bug?!
Post by: wp on July 02, 2018, 03:22:48 pm
I am the author of this example, but don't have access to Mac/carbon, and thus cannot reproduce on Win.

Double-click behavior of the standard grid was not modified in this example. Does the bug also occur with a standard string grid? There is a comment in TCustomGrid.DoEditorShow regarding carbon, but it has been there since at least version 1.6.4.

What exactly is the error message? Can you provide a stack trace?
Title: Re: Merge cells example bug?!
Post by: xinyiman on July 02, 2018, 03:44:41 pm
See if the images are clear enough.
Title: Re: Merge cells example bug?!
Post by: xinyiman on July 02, 2018, 03:44:58 pm
Other
Title: Re: Merge cells example bug?!
Post by: wp on July 02, 2018, 03:52:02 pm
Probably there is no editor. Modify TmcGrid.DoEditorShow like this and try again:

Code: Pascal  [Select][+][-]
  1. procedure TMCStringGrid.DoEditorShow;
  2. var
  3.   R: TRect;
  4. begin
  5.   inherited;
  6.   if goColSpanning in Options then begin
  7.     CalcCellExtent(Col, Row, R);
  8.     if Assigned(Editor) then   // <--- NEW
  9.       Editor.SetBounds(R.Left, R.Top, R.Right-R.Left-1, R.Bottom-R.Top-1);
  10.   end;
  11. end;
Title: Re: Merge cells example bug?!
Post by: xinyiman on July 02, 2018, 03:59:55 pm
He did not solve. But I do not understand a thing, if you look at the image 3 you will see that the right and the bottom of R are really great. Does not it seem strange?
Title: Re: Merge cells example bug?!
Post by: wp on July 02, 2018, 04:48:03 pm
Ah, uninitialized variable! Try this
Code: Pascal  [Select][+][-]
  1. procedure TMCStringGrid.DoEditorShow;
  2. var
  3.   R: TRect;
  4. begin
  5.   inherited;
  6.   if (goColSpanning in Options) and Assigned(Editor) then begin
  7.     R := CellRect(Col, Row);
  8.     CalcCellExtent(Col, Row, R);
  9.     Editor.SetBounds(R.Left, R.Top, R.Right-R.Left-1, R.Bottom-R.Top-1);
  10.   end;
  11. end;
  12.  
Title: Re: Merge cells example bug?!
Post by: xinyiman on July 02, 2018, 04:55:03 pm
Perfect. Thank you
Title: Re: (SOLVED) Merge cells example bug?!
Post by: wp on July 02, 2018, 05:51:18 pm
Applied to trunk. Thanks for reporting.
TinyPortal © 2005-2018