No announcement yet.

What is the reason for touch_Get(TOUCH_GETX)

  • Filter
  • Time
  • Show
Clear All
new posts

  • What is the reason for touch_Get(TOUCH_GETX)

    I am adding buttons to my code and I am looking at several of your examples. In the example FANCYBUTTONS(and others) there is code that reads the X & Y position as shown below. The question is I have is "Why do you read the x & y position?" I never see these variables used anywhere?


    touch_Set(TOUCH_ENABLE); // enable the touch screen repeat state := touch_Get(TOUCH_STATUS); // get touchscreen status n := img_Touched(hndl,-1) ; //----------------------------------------------------------------------------------------- if(state == TOUCH_PRESSED) // if there's a press x := touch_Get(TOUCH_GETX); y := touch_Get(TOUCH_GETY); if (n == iWinbutton1) img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, Wbs1+1); // where state is 0 for up, 1 for down, 2 for 'on' up and 3 for 'on' down img_Show(hndl,iWinbutton1) ; endif

  • #2

    Hi kenjustken,

    Yes, you can comment them out if you don't need them. I think they are just there to show the user that it is possible to get the X and Y coordinates of a touch. For the example you pointed out, since the function img_Touched(hndl,-1) returns the index of the fancy button object touched, the user obviously does not have to get and evaluate the touch coordinates. However, for multi-position objects like the slider, the user needs the X and Y coordinates to know which frame of the slider to display. So whether you comment them out or print their real time values on the screen - it's up to you.

    Hope this helps.