Tchart crashes on MouseMouse event is scale/range is not set yet lazarus / 55-TAChart ---------------------------------------------------------------------- stephanweber · 2024-06-17 06:40 Hi, I use the mouse moving event to update a little text label to show the coordinates. But to get the coordinates x and y the ranges need to be setup already. This is not the case on program startup, so if the mouse cursor is (e.g. by chance) over the chart I get a runtime error. To avoid this I created a boolean variable IsRun and use it in mouse- move event and initialize it in formcreate to False. However, I still get the same crash. What to do? Code: 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 procedure TFormMain.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);Var xx, yy : Double;begin  If IsRun then Begin   xx:=Chart1.XImageToGraph(X);  yy:=Chart1.YImageToGraph(Y);  LabelCursor.Caption:='Cursor: x=...';  endend; If I use If False all is fine.... Bye Stephan ---------------------------------------------------------------------- TRon · 2024-06-17 06:53 Hard to say without being able to see all the code/components/properties but as a general note: you can assign an event at runtime so would advise to try and set the event only after you have set the ranges correctly. ---------------------------------------------------------------------- stephanweber · 2024-06-17 07:32 Hi, it looks I found a solution: Using If Chart1.ScalingValid then ... works fine!! However, I still do not know why using the boolean variable instead does not work. Bye Stephan