Get Position on screen of a WebTextField

I want to show a palette below a webtextfield so I am trying to find out it’s real coordinates on the screen.

My idea was to loop through the parent and get its top and left coordinates using this code

[code]
dim parent as WebView = self.Parent
dim top as integer = self.top
dim left as integer = self.Left

while parent <> NIL
top = top + parent.Top
left = left + parent.Left
parent = parent.parent
wend[/code]

So far this works but the text field is place (inside containers) on a web dialog that is shown modal. The left and top properties of that dialog return 0.

Does somebody have an idea how to solve this?

Thanks a lot.

it seems to me only WebDialogs that are created on runtime don’t know their top and left positions.

Since you create the WebDialog, you must have set it’s position on the screen. Therefore it should be pretty easy to keep a reference to it.

no, a modal WebDialog is centered on the screen automatically.

But you can figure it out. You have page.width and the dialog’s width.

dialogX = (page.width - dialog1.width)/2

great idea Greg. Thanks a lot. will do it this way.
is there a plan to change / fix this in Xojo or is it the way it is meant to be?

<https://xojo.com/issue/26549>

[quote=302685:@Fabian Eschrich]great idea Greg. Thanks a lot. will do it this way.
is there a plan to change / fix this in Xojo or is it the way it is meant to be?[/quote]
The issue is that the “control” includes the dark overlay. It was an original design flaw and fixing the behavior challenging to put it simply.

It does not seem completely impossible to get these values. Since the overlay covers the entire browser window, offsetLeft and offsetTop give the correct left and top. Here in a button placed on the dialog :

[code]Sub Action() Handles Action
dim js as string

js = js + “var dlg = document.getElementById(’”+self.ControlID+"_body’);"
js = js + “alert(dlg.offsetLeft + ‘x’ + dlg.offsetTop);”

self.ExecuteJavaScript(js)

End Sub
[/code]