Move components problem

Hello guys,
I have the following code binding to a slider object to move a works fine.
I wanted to implement the same logic using two buttons ; one that moves the component UP and one that moves it DOWN. I am running into a series of issues ; if i simply decrement the origY by -5 or +5 the object does not move by 5 pixels...(what am i doing wrong)
Thanks and regards,

component = event.source.parent.getComponent("elev")
origX = 26
origY = 465

component, 26, origY-event.source.value,


event.source.parent.getComponent('labelY').text = str(origY)

Did you use the exact same code on your buttons ?
If not, show us the code that doesn't work, not the one that does.
And enclose your code in triple backticks, like that:

code goes here

1 Like

This is the code binding on mousePressed for the button UP ; in the button DOWN I simply add +5 in the dest variable and check that dest does not go beyond 465

move = True
component = event.source.parent.getComponent("elev")
dest = component.y - 5

if dest < 170:
	move = False

if move:
		26, dest

I think you'll find it's a screen size thing. 9 times out of 10, your client screen will be a different size, if only slightly, to what you developed it as. In that case, absolute 5px on a client might actually be different base on the scaling applied. You should look at using the designer coordinate space instead of the client coord space so that your fixed pixel values are scaled accordingly in the client (it's an arg you provide into the transform function)

1 Like

So I'm not familiar with vision (I expect this to be vision), but I can suggest a simplification for your script:

component = event.source.parent.getComponent("elev")
dest = component.y - 5

if dest >= 170:
	system.gui.transform(component, 26, dest)
	event.source.parent.getComponent('beltDX').relHeight -= 5
	event.source.parent.getComponent('beltSX').relHeight -= 5

Your first if statement doesn't actually do anything except for setting up the second if condition.
You're assigning a value to dest, which will not be used since if entering this part of the code, move becomes false and the second if is not entered.
So, might as well get rid of that first if, and reverse the condition to enter the second one.


relHeight is not correct for movement. This is a size parameter. The movement parameters are relX for horizontal movement and relY for vertical movement

1 Like