[Solved] TDrawGrid gdPushed not working lazarus / 31-LCL ---------------------------------------------------------------------- lainz · 2018-01-19 18:02 Hi, attached is this code using TDrawGrid, I want to change the color (bgc: TColor) to clGray when the cell is pushed (mouse down). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if gdPushed in aState then    bgc := clGray;   Mouse over (gdHot) is working fine as you can test, but pushed is not working. Maybe I'm missing a setting or two. All the settings are set by code, I'm not using the object inspector. Thanks. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, Math, Types; const  PANEL_BUTTON_WIDTH = 100;  PANEL_BUTTON_HEIGHT = 65;  PANEL_MIN_COLS = 4;  PANEL_MIN_ROWS = 3; type   { TForm1 }   TForm1 = class(TForm)    DrawGrid1: TDrawGrid;    procedure DrawGrid1DrawCell(Sender: TObject; aCol, aRow: integer;      aRect: TRect; aState: TGridDrawState);    procedure FormCreate(Sender: TObject);    procedure FormResize(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormResize(Sender: TObject);begin  DrawGrid1.ColCount := Max(Width div PANEL_BUTTON_WIDTH, PANEL_MIN_COLS);  DrawGrid1.RowCount := Max(Height div PANEL_BUTTON_HEIGHT, PANEL_MIN_ROWS);end; procedure TForm1.FormCreate(Sender: TObject);begin  DrawGrid1.HeaderHotZones := [gzNormal];  DrawGrid1.HeaderPushZones := [gzNormal];  DrawGrid1.Options := [goHeaderPushedLook, goHeaderHotTracking];  DrawGrid1.DefaultDrawing := False;  DrawGrid1.BorderStyle := bsNone;  DrawGrid1.FixedCols := 0;  DrawGrid1.FixedRows := 0;  DrawGrid1.GridLineWidth := 0;  DrawGrid1.DefaultColWidth := PANEL_BUTTON_WIDTH;  DrawGrid1.DefaultRowHeight := PANEL_BUTTON_HEIGHT;end; procedure TForm1.DrawGrid1DrawCell(Sender: TObject; aCol, aRow: integer;  aRect: TRect; aState: TGridDrawState);var  bgc: TColor;  grid_canvas: TCanvas;begin  grid_canvas := TDrawGrid(Sender).Canvas;   if gdHot in aState then    bgc := clGreen  else    bgc := clMoneyGreen;   if (aRow = 0) then  begin    if gdHot in aState then      bgc := clBlue    else      bgc := clSkyBlue;  end;   if gdPushed in aState then    bgc := clGray;   grid_canvas.Brush.Color := clWhite;  grid_canvas.FillRect(ARect);  grid_canvas.Brush.Color := bgc;  grid_canvas.FillRect(ARect.Left + 4, ARect.Top + 4, ARect.Right - 4, ARect.Bottom - 4);end; end. ---------------------------------------------------------------------- Blaazen · 2018-01-19 18:32 gdPushed is related to header cells only. You set FixedRows := 0 therefore you don't see it. Try set it to 1 and the top row will be gray on click. ---------------------------------------------------------------------- lainz · 2018-01-19 18:41 Quote from: Blaazen on January 19, 2018, 07:32:23 pmgdPushed is related to header cells only. You set FixedRows := 0 therefore you don't see it. Try set it to 1 and the top row will be gray on click. Hi, well I set it to 1 and did not work. Is strange because there is a setting for that, not only the headers: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DrawGrid1.HeaderHotZones := [gzNormal];DrawGrid1.HeaderPushZones := [gzNormal];DrawGrid1.Options := [goHeaderPushedLook, goHeaderHotTracking]; Is the same setting for push and hot. Hot works and Push does not. ---------------------------------------------------------------------- lainz · 2018-01-19 18:50 "Fixed", is not as it should work according to the provided settings as I explained in my message above, but I don't have a reason to fill a bug in the bugtracker. Adding this line OnResize (preventing errors when changing fixed rows): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...  r := Max(Height div PANEL_BUTTON_HEIGHT, PANEL_MIN_ROWS);  if (r > DrawGrid1.FixedRows) then  begin    DrawGrid1.RowCount := r;    DrawGrid1.FixedRows := r;  end  else  begin    DrawGrid1.FixedRows := r;    DrawGrid1.RowCount := r;  end;... And removing this line: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...//DrawGrid1.HeaderPushZones := [gzNormal];...