Mouse coordinates but relative to dialog's window

We'll add methods for this in the next beta.

Example of how it can be used:

Script Code:

function OnClick(clickData)
{
	var dlg = DOpus.Dlg();
	dlg.window = clickData.func.sourcetab;
	dlg.template = "mousePosDialog";
	dlg.detach = true;
	dlg.Create();
	dlg.SetTimer(100, "mouseTimer");
	dlg.Show();

	var ctrlSX = dlg.Control("staticSX");
	var ctrlSY = dlg.Control("staticSY");
	var ctrlCX = dlg.Control("staticCX");
	var ctrlCY = dlg.Control("staticCY");

	while(true)
	{
		var msg = dlg.GetMsg();
		if (!msg.result)
			break;
		if (msg.control == "mouseTimer")
		{
			var t = dlg.ScreenToClient(msg.mousex, msg.mousey);
			ctrlSX.label = String(msg.mousex);
			ctrlSY.label = String(msg.mousey);
			ctrlCX.label = String(t.left);
			ctrlCY.label = String(t.top);
		}
	}
}

Resources:

<resources>
	<resource name="mousePosDialog" type="dialog">
		<dialog height="48" lang="english" title="Mouse Pos Example" width="114">
			<control halign="left" height="8" name="static1" title="Screen:" type="static" valign="top" width="30" x="12" y="12" />
			<control halign="center" height="8" name="staticSX" title="SX" type="static" valign="top" width="20" x="48" y="12" />
			<control halign="left" height="8" name="static4" title="x" type="static" valign="top" width="6" x="72" y="12" />
			<control halign="center" height="8" name="staticSY" title="SY" type="static" valign="top" width="20" x="84" y="12" />
			<control halign="left" height="8" name="static2" title="Client:" type="static" valign="top" width="30" x="12" y="30" />
			<control halign="center" height="8" name="staticCX" title="CX" type="static" valign="top" width="20" x="48" y="30" />
			<control halign="left" height="8" name="static5" title="x" type="static" valign="top" width="6" x="72" y="30" />
			<control halign="center" height="8" name="staticCY" title="CY" type="static" valign="top" width="20" x="84" y="30" />
		</dialog>
	</resource>
</resources>
1 Like