Forum > LCL

Local and global mouse cursor settimgs

(1/1)

simsee:
I'm developing an application that requires different mouse cursors depending on the controls it's on. Therefore I did some preliminary experiments and found unexpected behaviors.

To decide which cursor appears over a control, I can set its Cursor property. This setting has a local effect. I can globally set the cursor for all visible controls using Screen.Cursor.

What I noticed is that if I set before Screen.Cursor, after the local settings have no effect. This is shown by the demo program that I attach, in which, with one button you set the global cursor, using Screen.Cursor, with the other the local one of a Panel, with TPanel.Cursor.

Is this behavior correct and expected? Is it possible to set the local cursor on a control after setting the global one? Or do I have to set the cursors of the various controls individually, without touch Screen.Cursor?

Thanks.

jamie:
Yup,. That seems to be how I remember it.

Martin_fr:
Yes, afaik correct.

But once you do

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Screen.Cursor:=crDefault;the local setting will be in effect.

Screen.Cursor overrides all local cursors. You can't have a single control exempt from it.

You can have onMouseEnter/Leave for that control, and change the screen cursor and restore it....

ASerge:

--- Quote from: Martin_fr on February 17, 2024, 10:17:35 pm ---You can have onMouseEnter/Leave for that control, and change the screen cursor and restore it....

--- End quote ---
Using existing methods:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Panel1MouseEnter(Sender: TObject);begin  Screen.BeginTempCursor((Sender as TControl).Cursor);end; procedure TForm1.Panel1MouseLeave(Sender: TObject);begin  Screen.EndTempCursor((Sender as TControl).Cursor);end;

Navigation

[0] Message Index

Go to full version