# Get Position on screen of a WebTextField

**URL:** <https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890>\
**Category:** Web\
**Created:** [December 10, 2016, 10:16am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890 "2016-12-10T10:16:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian\_Eschrich](https://forum.xojo.com/user_avatar/forum.xojo.com/fabian_eschrich/32/292_2.png) [@Fabian\_Eschrich](https://forum.xojo.com/u/Fabian_Eschrich)\
**Post date:** [December 10, 2016, 10:16am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/1 "2016-12-10T10:16:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Fabian\_Eschrich](https://forum.xojo.com/user_avatar/forum.xojo.com/fabian_eschrich/32/292_2.png) [@Fabian\_Eschrich](https://forum.xojo.com/u/Fabian_Eschrich)\
**Post date:** [December 11, 2016, 9:32am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/2 "2016-12-11T09:32:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 11, 2016, 11:00am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/3 "2016-12-11T11:00:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Fabian\_Eschrich](https://forum.xojo.com/user_avatar/forum.xojo.com/fabian_eschrich/32/292_2.png) [@Fabian\_Eschrich](https://forum.xojo.com/u/Fabian_Eschrich)\
**Post date:** [December 11, 2016, 11:03am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/4 "2016-12-11T11:03:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [December 11, 2016, 11:10am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/5 "2016-12-11T11:10:45Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Fabian\_Eschrich](https://forum.xojo.com/user_avatar/forum.xojo.com/fabian_eschrich/32/292_2.png) [@Fabian\_Eschrich](https://forum.xojo.com/u/Fabian_Eschrich)\
**Post date:** [December 11, 2016, 11:18am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/6 "2016-12-11T11:18:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 11, 2016, 11:47am UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/7 "2016-12-11T11:47:43Z")

</div>

\<[https://xojo.com/issue/26549](https://xojo.com/issue/26549)\>

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [December 11, 2016, 12:02pm UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/8 "2016-12-11T12:02:38Z")

</div>

[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.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 11, 2016, 1:04pm UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/9 "2016-12-11T13:04:51Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:34pm UTC](https://forum.xojo.com/t/get-position-on-screen-of-a-webtextfield/34890/10 "2020-10-29T18:34:40Z")

</div>


