# \[Solved\] Get computed width/height blocks not working in DnD

**URL:** <https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330>\
**Category:** Questions about Thunkable X\
**Tags:** solved, bugs, bug\
**Created:** [November 5, 2021, 4:24pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330 "2021-11-05T16:24:23Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 5, 2021, 4:24pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/1 "2021-11-05T16:24:23Z")

</div>

I am attempting to pick up on the width of the canvas by using the block “canvas computed width”. When i use this block, it returns `0`. The way I am using it, I would expect to recieve a positive value because my canvas does in fact have width when I view it.

What i want to do is touch the canvas and save the proportionate position of the click and not the pixel value. This is the only way to scale the positions across devices seamlessly AFAIK.

 ![Screen Shot 2021-11-05 at 12.20.13 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/c/ec60777833e38fb87eba0a199b780b19dac01d18.png)

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [November 5, 2021, 4:30pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/2 "2021-11-05T16:30:51Z")

</div>

You get 0 value because that canvas didn’t displayed yet.  
Try to put something like this, between the creation of canvas and that retrieving its dimensions:  
repeat while canvas1’s computed width = 0  
wait 0.001

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 5, 2021, 4:33pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/3 "2021-11-05T16:33:44Z")

</div>

> [@mimostel](#):
>
> splayed yet.  
> Try to put something like this, between the creatio

Thanks for the input. The canvas is always displayed before i try any action. This is unlikely as even with this setup I receive the 0 value.

 ![Screen Shot 2021-11-05 at 12.32.54 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/c/0c98d6da20eb4f56f665ea3440ee68c71ec8d765.png)  
^^^also doesnt work

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [November 5, 2021, 4:35pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/4 "2021-11-05T16:35:04Z")

</div>

Ah, I read all wrong, I’m sorry. Thought you get zero as canva`s width and height.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 5, 2021, 4:36pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/5 "2021-11-05T16:36:08Z")

</div>

You read right.

Specifically, when I ask to return the value of the computed Height or Width of Canvas1, the blocks return the value of 0 even though I have hard set the value at 375 pixels.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 5, 2021, 5:01pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/7 "2021-11-05T17:01:53Z")

</div>

Like i

> [@mimostel](#):
>
> cond” with my loop and see.

what loop are you referencing?

> [@mimostel](#):
>
> thing: when you try to retrieve computed values, the object must be visible. If hidden (can’t tell from that screen if is so), computed height/width are zero

As i stated above, the canvas is always visible when this action happens. In fact, the canvas must to be visible since the action is a click on the canvas itself.

I appreciate you trying here but this is an odd bug. I have already reported it via intercom

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 5, 2021, 5:25pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/8 "2021-11-05T17:25:59Z")

</div>

Can you place a dot in each corner of the canvas and get their coordinates?

Haven’t tried it myself but logically you can compute the size.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 5, 2021, 5:27pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/9 "2021-11-05T17:27:28Z")

</div>

No matter what I try, I can’t get the canvas’ computed width to be anything but zero. Not when screen opens, not when canvas loads, not when pointer is down, not when button is clicked…

Just confirming what you already know.

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [November 5, 2021, 5:47pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/11 "2021-11-05T17:47:42Z")

</div>

> [@muneer](#):
>
> Can you place a dot in each corner of the canvas and get their coordinates?

This is a great idea, and will work to manually calculate sizes, but only if they can retrieve coordinates 🤔

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 5, 2021, 5:53pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/12 "2021-11-05T17:53:52Z")

</div>

this would also imply that someone needs to place the points first, right? I’l try this out iinstead of waiting on an answer

i guess a better question is: If I set the canvas to 375 pixels in the editor, will ALL screen sizes respect this width? anyone wanna sample this with me? I am on an iphone 11 and would need to see the results on something like an android

my answer is here

 ![Screen Shot 2021-11-05 at 1.57.59 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/8/68efed92b00d5d61a6dcfed18248f763dd58f951.jpeg)  
and it’s no. if i set this to be 375, the app will try to apply these sizes to different screen sizes, which is nice but doesnt help when i cant get the value of the canvas easily

it’s actuallly a yes i think. no matter the screen size i test them on, the app always interpret the distance as 375 pixels.

the idea is that i want to make a marker on an image in my app, then view it on any other device and make sure that the marker falls in the same spot without modifying the original image in the first place.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [November 6, 2021, 7:59am UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/13 "2021-11-06T07:59:46Z")

</div>

I placed a canvas in the screen and added a `Sprite Type`. I used the new sprite type to place one in the top left and one in the bottom right. I then get the position of the sprite which will aid in calculating the size.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/f/cfad4256fb7340567fd4a504074a9545643ecb39.png)

Of course you will choose a sprite image that is less obvious that what I used but I needed to see them in the screen.

**[Edit]**

After giving it some thoughts, you don’t need the sprite in the top left corner because it is (0,0) so the only sprite you will need is the bottom-right corner which is approx. (290, 440)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 6, 2021, 1:43pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/14 "2021-11-06T13:43:19Z")

</div>

> [@muneer](#):
>
> sed the new sprite type to place one in the top left and one in the bottom right. I then get the position of the sprite which will aid in calculating the size.

so oddly enough, when i published this as a webapp on a it registers the same number of pixels when viewed on my computer as on my iphone. (maybe due to dpi) but its also the same as when viewed on the live app. in 2 of those 3 places the image is the same size but on my computer the webapp image is bigger than 375 pixels for sure but only registers as such. so, in my mind, the React Native engine is (in the background) stretching pixels which isn’t a thing but more likely they are using a CSS Scale feature to up/down the size thereby saving pixel density… in my mind that’s whats happening anyway. perhaps someone like @Steven could comment on the system behind sizing up and down between screen sizes and what that does to pixel locations and pixel coordinates on bigger/smaller screens when everything is set in fixed pixel sizes using the new editor.

---

<div class="post-metadata">

**Author:** ![cassandra](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cassandra/32/115809_2.png) [@cassandra](https://community.thunkable.com/u/cassandra)\
**Post date:** [November 8, 2021, 6:47pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/15 "2021-11-08T18:47:42Z")

</div>

Hi @jared - thanks for reporting this, and everyone else for helping out. I’ve shared with our engineering team and we will investigate further soon!

---

<div class="post-metadata">

**Author:** ![paulmw](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@paulmw](https://community.thunkable.com/u/paulmw)\
**Post date:** [November 8, 2021, 7:27pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/16 "2021-11-08T19:27:51Z")

</div>

@jared In the stage drawer, get any of the blocks that return a value. Then change the property to be “Height” or “Width”. This will give you the size of the canvas that is used for the sprite coordinates.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/2/02686b8ef912265ece289cf899f8f43817227b14.png)

I don’t know why the Height/Width aren’t available in the drawer by default. We’ll fix this in a future release.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [November 9, 2021, 12:08am UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/17 "2021-11-09T00:08:58Z")

</div>

Thank you @paulmw, I can confirm those blocks do, in fact, work to produce the desired result!

Here was my final (simple) test case

 ![Screen Shot 2021-11-08 at 7.08.44 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/7/9781e00728953412782ae2de0fe43422edcc2f17.png)

The use case here, btw, is so that I can recreate this same image/dropped points combo on any device! I’ll send this off to Firebase and recall it later on a computer in a webapp!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:14pm UTC](https://community.thunkable.com/t/solved-get-computed-width-height-blocks-not-working-in-dnd/1599330/18 "2024-11-08T13:14:27Z")

</div>


