Cursor position in Timage lazarus / 39-Graphics ---------------------------------------------------------------------- barsoom · 2021-08-16 21:54 I am working with an image, and, for the moment, i need to know the position (coordinates) of the cursor in the image. To do that, i have a Timage, and a label. In the Timage, i added this code to the events 'OnmouseMove' and 'Onmouse leave' 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 to show the (relative) coordinates of the cursor on the imageprocedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);begin  Label1.Caption := Format('%d,%d', [X, Y]);  // way 1  //Label1.caption:= '('+IntToStr(X)+','+IntToStr(Y)+')'; // way 2end;   // Procedure to clear the label when the mouse leave the imageprocedure TForm1.Image1MouseLeave(Sender: TObject);begin  Label1.caption := '';end;  As you can see, in 'OnMouseMove' event i tried two different ways to show the coordinates in the label caption. However, although both ways 'work' somehow, the result is the same in boths, and here is the problem: The coordinates are only updated once the mouse stop on the image, but coordinates are not updated meanwhile the cursor is under movement on the image. I googled a lot and the procedure seems to be ok, but i do not know why i have these behaviour. Any idea about what i am doing wrong? Thanks! ---------------------------------------------------------------------- wp · 2021-08-16 22:10 On which OS/widgetset is this? On Windows, Ubuntu/gtk2 and Ubuntu/qt5 it works correctly. ---------------------------------------------------------------------- barsoom · 2021-08-16 22:34 It is under OS Windows 10 64bits and Lazarus version 2.0.4 FPC 3.0.4 SVN 61665 ---------------------------------------------------------------------- wp · 2021-08-16 22:43 My oldest Lazarus of the v2.0.x series is v2.0.8, and it does not show the issue. And of the 1.x series I have v1.8.4, and it does not show the issue either. So, I have no idea what's going on here. Please try to write a little demo project showing the issue and post it here. Maybe the bug is somewhere else. ---------------------------------------------------------------------- barsoom · 2021-08-16 23:18 @thanks @wp, One more time, you are right... I tried a simple example project, and it worked... then, i added the image inside a scrollbox, as i have in my project... and it worked... BUT, when i changed the autoscroll option of the scrollbox to True, it stop to work correctly. Then, it show the values only when the mouse stop the movement. The "funny" issue is that it affect to all the images loaded in the form!! Take a look to the example project i prepared. I load a image in two Timage containers. One is directly in the form, and the second one inside a scrollbox. Play with the checkboxes to chnage some properties of the scrollbox, and you will see how it affect to the position information update. ---------------------------------------------------------------------- dsiders · 2021-08-16 23:21 Quote from: barsoom on August 17, 2021, 12:34:03 amIt is under OS Windows 10 64bits and Lazarus version 2.0.4 FPC 3.0.4 SVN 61665 Does not have any issues on 2.2.0-RC1 or using 2.3.0 from Git. Windows 8.1, 64-bit, FPC 3.2.0 and 3.2.2. ---------------------------------------------------------------------- wp · 2021-08-17 16:58 I can confirm the issue with both Laz 2.3 and Laz 1.8.4. It is required that the image loaded into the TPicture is quite large (at first I simply selected the application icon which is too small to see an effect). There is also some flicker of the scrollbox border when the mouse is moved. Therefore, I think that the scrollbox enforces a repaint of the image with every mouse-move. To check this, I added an OnPaint handler to the image which simply counts up a number with every repaint requested: 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  Counter: Integer = 0;procedure TForm1.Image2Paint(Sender: TObject);begin  inc(Counter);  WriteLn(TControl(Sender).Name, ': ', Counter);end; In fact, the counter increments with every move of the mouse. When I hook this event handler also to Image1 (the one outside the scrollbox) I can see that the paint requests always originate from Image2, even when the mouse is outside Image2 - very strange... I repeated the test on a VM with Ubuntu and found that there the repaints do not occur and the cursor display in the test program updates instantly. Therefore, I guess that the issue is related to the windows widgetset only. I think I saw a similar bug report recently, but cannot find it at the moment. ---------------------------------------------------------------------- barsoom · 2021-08-18 20:37 Thanks @dsiders and @wp! @wp, you are right, it occurs with relative big picture files. I also tested other properties of the scrollbox to see how it affect this issue. If you define the range of each scrollbar, the described behaviour seems to "dissapear as well.