Bitmap HitTest is missing?

I am trying to replace the TTMSFMXGrid with the TTMSFNCGrid component in several of my software and running into issues.

In the following TTMSFMXGrid event handler, you have access to the HitTest for a given bitmap cell as follows:

procedure TMainForm.GridGetCellAppearance(Sender: TObject; ACol,
ARow: Integer; Cell: TFmxObject; ACellState: TCellState);
begin
if (ARow = 0) and (Cell is TTMSFMXBitmapGridCell) then (Cell as TTMSFMXBitmapGridCell).Bitmap.HitTest := false;
end;

first, in the FNC Grid component, the OnGetCellAppearance event handler is not available. So, I am trying to use the OnGridGetCellProperties event instead. But the following code won't work because the HitTest is not available

procedure TMainForm.PinGridGetCellProperties(Sender: TObject; ACol,
ARow: Integer; Cell: TTMSFNCGridCell);
begin
if (ARow > 0) and ((Cell is TTMSFNCBitmapGridCell)) then (Cell as TTMSFNCBitmapGridCell).HitTest := false; //<<<< this is not available
end;

also, I cannot seem to get the OnGridCellBitmapClick event to work.

what I am trying to do is add an image to each fixed cell at the top row. when the user clicks the image, I show my own custom column filters form.

The problem is, when I insert a bitmap into the top fixed cells, I can no longer sort the columns when clicking the fixed cell. in other words, the bitmap is taking all the clicks and I need the click to go through the bitmap onto the cell so the sorting can also work.

even if I insert buttons instead of bitmaps, the column sorting won't work as well.

Is there a way to expose the HitTest property for bitmaps in fixed cells?

I am hoping someone can point me in the right direction or possibly suggest another solution.

thanks for your time,

Dave

Hello Guindon David.

I cannot seem to get the OnGridCellBitmapClick event to work.

I think it's true, my temporary solution to the same problem
was to use the OnCellclick method and ask for the column where they clicked

1 Like

Hi,

The default behaviour is showing a bitmap that is not clickable. It is just part of the cell being visualized. If you want to enable clicking on the bitmap you can use the following code:

procedure TForm1.TMSFNCGrid1CellBitmapClick(Sender: TObject; ACol,
  ARow: Integer; ACell: TTMSFNCGridCell);
begin
  TTMSFNCUtils.Log('bitmap clicked at ' + ACol.ToString + ':' + ARow.ToString);
end;

procedure TForm1.TMSFNCGrid1GetCellProperties(Sender: TObject; ACol,
  ARow: Integer; Cell: TTMSFNCGridCell);
begin
  if (Cell is TTMSFNCBitmapGridCell) then
    (Cell as TTMSFNCBitmapGridCell).ControlEnabled := True;
end;
1 Like

Great, thanks! I got the bitmap click event to work and also found this handy property for placing the bitmap where I want it:

(Cell as TTMSFNCBitmapGridCell).ControlPosition := TTMSFNCGridCellControlPosition.gcpRight;

also .. I was able to overcome the issue of sorting/multi-column sorting by manually coding it all in the OnFixedCellClick event

thanks for the help :grinning:

1 Like

Thanks for the feedback!

1 Like