Forum Discussion

NThomas's avatar
NThomas
Occasional Contributor
10 years ago

Component offset from the visual

Hello !   I just created a new project to test the TC Mobile module 10. Everything works properly (installation, smartphone emulation, ...).   I just have a problem, because when I use object sp...
  • NThomas's avatar
    NThomas
    10 years ago

    Hello,


    I found a solution by taking the width and height of the smartphone and I divisie to the width and height of the application to give me a zoom factor :

     

    var oMobile = Mobile.Device("RAINBOW");
    var oRootLayout = oMobile.FindChild('ObjectType', 'RootLayout', 5);
        
    var iCoefHeight = oMobile.Desktop.Height / oRootLayout.Height;
    var iCoefWidth = oMobile.Desktop.Width / oRootLayout.Width;

    I look for the component and a variable, I store the new X and Y coordinates by adding the zoom factor to click in the middle of the component :

     

    var oComponent = oRootLayout.FindChild(new Array('ObjectType', 'textContent'), new Array('TextNode', "Démarrer l'application"), 50);
    
    var iComponentCoordinateX = (oComponent.ScreenLeft * iCoefWidth) + ((oComponent.Width * iCoefWidth) / 2); 
    var iComponentCoordinateY = (oComponent.ScreenTop * iCoefHeight) + ((oComponent.Height * iCoefHeight) / 2);

    Then I click on the mobile to coordinated X and Y found :

     

    oMobile.Touch(iComponentCoordinateX, iComponentCoordinateY);

    Here is a solution if you ever have the problem.


    Tanya thank you for your help.

     

    Have a great day.

    Nicolas