MouseToCell lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- straetch · 2017-11-06 12:04 Hello, In my TWorksheetGrid I have an OnClick handler. The active cell is set to the cell that is clicked - as expected. I also want to be able to browse the grid and right-click a cell. The handler should then give additional information on the cell. However, the cell should NOT become active in the grid. So, I have a normal TWorksheetGridClick handler plus a TWorksheetGridMouseDown handler with a statement like     if Button = mbRight then .... The problem is that I cannot derive the cell coordinates from the X and Y values passed to the handler. The standard TStringGrid has a MouseToCell method, used as   ThisCell := StringGrid1.MouseToCell(X,Y). TWorksheetGrid does not seem to have a MouseToCell method. Is there an alternative? Thanks. Lazarus 1.6, FPSpreadsheet version dated june 17, 2017. ---------------------------------------------------------------------- Mike.Cornflake · 2017-11-06 16:25 QuoteTWorksheetGrid does not seem to have a MouseToCell method. Yes it does.  The below compiles and works for me.  Oh, I'm using Laz 1.9.  My copy of fpspreadsheet is circa March 2017.  Doubt the higher build of Laz would be an issue though, not for MouseToCell. 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 Var  mouseCell: TPoint;  r, c: Cardinal; Begin  mouseCell := GRID.MouseToCell(Point(X, Y));  c := GRID.GetWorksheetCol(mouseCell.X);     r := GRID.GetWorksheetRow(mouseCell.Y);   End (Shamelessly ripped from the source code :-) ) ---------------------------------------------------------------------- straetch · 2017-11-07 08:16 It does work. Thanks. I did not find the method in the api documentation. I could and should have tried it with TStringGrid as example. ---------------------------------------------------------------------- wp · 2017-11-07 08:46 Quote from: straetch on November 06, 2017, 01:04:36 pmIn my TWorksheetGrid I have an OnClick handler. The active cell is set to the cell that is clicked - as expected. I also want to be able to browse the grid and right-click a cell. The handler should then give additional information on the cell. However, the cell should NOT become active in the grid.If I understand you correctly - this is what the WorksheetGrid is doing: if you right- click on a cell then the cell is *not* selected. Quote from: straetch on November 06, 2017, 01:04:36 pmTWorksheetGrid does not seem to have a MouseToCell method.The WorksheetGrid inherits from TCustomDrawGrid and, therefore, has all the methods that TCustomDrawGrid and TCustomGrid have. Since TStringGrid inherits from TCustomDrawGrid as well and thus follows a different lineage, TsWorksheetGrid does not share the methods and properties introduced by TStringGrid itself, but there's a good chance that most of the methods that you may know from TStringGrid will work for TsWorksheetGrid. ---------------------------------------------------------------------- straetch · 2017-11-07 09:27 QuoteIf I understand you correctly - this is what the WorksheetGrid is doing: if you right-click on a cell then the cell is *not* selected.Exactly, if you right-click a cell in a WorksheetGrid, it is not selected. That seems the correct way and that is what I was looking for: a way to give context to a user without activating anything. QuoteThe WorksheetGrid inherits from TCustomDrawGrid and, therefore, has all the methods that TCustomDrawGrid and TCustomGrid have.Indeed, I looked only in the documentation of TsWorksheetGrid. I should have tried with the method, described for it's ancestor.