discrepancy with Panel in Designer Script

enonod

Well-Known Member
Licensed User
Longtime User
V2.30
I had initially used Designer to lay out views, it worked, but I decided to script the sizes and positions. It also worked (almost). Shown below...

B4X:
'All variants script
'AutoScaleAll 'uncomment to scale all views based on the device physical size.
lblStatus.Left = 0dip
lblStatus.Bottom = 100%y
lblStatus.Width = 100%x
lblStatus.Height = 40dip

tbnStart.Left = 0%x
tbnStart.Width = 70dip
tbnStart.Height = 70dip
tbnStart.Bottom = lblStatus.Top

tbnInterim.Right = 100%x
tbnInterim.Width = 70dip
tbnInterim.Height = 70dip
tbnInterim.Bottom = lblStatus.Top

pnlControl.Bottom = lblStatus.Top -10
pnlControl.Left = tbnStart.Right     '[2]
pnlControl.Right = tbnInterim.Left  '[1]
   'pnlControl.Width = 100%x - tbnStart.Width - tbnInterim.Width
pnlControl.Height = 70dip

I spent some time trying to fathom why my script required a correcting factor as shown above, of -10, to sit the Panel on the top of the Label. While all the information seemed correct, the problem was caused by the original design (non script) showed the height of the Panel as 60, whereas it was now required to be 70.

I cannot believe that when a script is added the original figures do not update or alternatively get ignored. Otherwise we have to edit in two places??
Especially as the Tutorial says that the initial design does not need to be accurate.

Also if I add... pnlControl.Width = 100%x - tbnStart.Width - tbnInterim.Width ...then on a wider device the pnlControl does not stretch the width between the two buttons as it does with or without this line on the original 320 x 480 scale = 1 device.
Leaving the above line in and then removing that marked [1] solves it but leaving [1] in and removing [2] does not.

Please enlighten me.
 
Last edited:

enonod

Well-Known Member
Licensed User
Longtime User
Yes Erel, a small oversight but it should not be needed at all, because the Panel should sit on the top edge of the Label without -10dip.
The reason it does not sit correctly is because in the original design using the Designer (left hand Tab) where one fills in the properties in boxes it originally had 60 for the height. I now changed my mind and decided to script and do a better job.

My new script (right hand Tab 'Designer Scripts') says 70. Therefore to correct this I have to script for 70 and then go back to the original design boxes and also change that from 60 from 70.
I simply cannot see why I have to do this change in two places to get it right.

The tutorial says that the original design of placing items does not need to be accurate, which leads me to believe that the original design gets updated by the script and the boxes with original numbers would change.

If this is not clear I will have another go at explaining.
[Edit] i.e. the Height 70 in the script does not override the 60 in the property box however the position settings in the script DO override those in the property boxes.
 
Last edited:
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
It is set by Bottom and Height. Unless that is not a valid way to do it but it 'seems' right to me not to have to manually calculate it when designer could/should manage that?
I crossed in the post and had edited my first reply which might help. I also edited my first post at the bottom with another question.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code is wrong (does not do what you expect):
B4X:
lblStatus.Bottom = 100%y 
lblStatus.Height = 40dip
The first line will move the label to the bottom of the activity.
The second line will change the label's height. It will not change the label's position (position = top, left corner).

The correct code:
B4X:
lblStatus.SetTopAndBottom(100%y - 40dip, 100%y)

Or you can first set the height and then set the bottom property.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Thank you Erel. I believe I now understand that this is a sequential process as opposed to feeding in information that then calculates remaining 'missing' properties.
I believe I understand that your correction suggests that the sequential nature of single changes can be overcome by certain commands that are a combination of what would be two separate ones.

If that is correct then it makes sense and I guess I should have seen that it was sequential.
 
Upvote 0
Top