Announcement

Collapse
No announcement yet.

objTouched := img_Touched but not for me

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • objTouched := img_Touched but not for me

    Been pulling my hair out for days to get a simple bit of code to work with out having to detect a user push button based on co-ordinates.
    I have a user button ( 2 images) and am trying to implement the objTouched := img_Touched function but with out any success.

    img_ClearAttributes(hndl, iUserbutton8, I_TOUCH_DISABLE);
    img_Show(hndl,iUserbutton8); //display button

    repeat
    var touchx, touchy;
    var touchState, objTouched;
    touchState := touch_Get(TOUCH_STATUS);
    objTouched := img_Touched(hndl, -1);
    touchx := touch_Get(TOUCH_GETX);
    touchy := touch_Get(TOUCH_GETY);


    if(touchState == TOUCH_PRESSED)
    if(objTouched == iUserbutton8)
    img_SetWord(hndl, iUserbutton8, IMAGE_INDEX, 1); // if button touched the show pressed image
    img_Show(hndl,iUserbutton8) ;
    endif

    else if(touchState == TOUCH_RELEASED);
    if(objTouched == iUserbutton8)
    img_SetWord(hndl,iUserbutton8, IMAGE_INDEX, 0); // if button release show unpressed image
    img_Show(hndl,iUserbutton8) ;
    break ;
    endif
    endif



    I just cant get the objTouched := img_Touched to recognise my button being pressed




  • #2
    I am having a similar issue myself. I assume you have touch_Set(TOUCH_ENABLED) in your main function?

    Comment


    • #3
      Hi,


      As mentioned above, you need to enable the touch hardware first. Then, that's how should look like as shown below:

      Code:
      func main()
      
          touch_Set(TOUCH_ENABLE);
      
          repeat
          forever
      
      endfunc

      And also, uncomment the "break' on your code because this command will halt anything that is running. Also, this command is often used for "switch case" conditional statement.



      Best regards,
      Kayven
      Last edited by kayven@4d; 9th August 2018, 12:32 PM.

      Comment


      • #4
        Yes sorry, touch has been enabled, also the code its just a test function i had put in place as had stripped code to bare minimum for the touch test.

        Comment


        • #5

          Hi,

          It seems you're doing it correctly.

          Please go to "C:\Users\Public\Documents\4D Labs\Picaso Designer\PICASO - TOUCH SCREEN " then do a touch test by running the program "TOUCHTESTDRAW.4DG" and observe if there's any touch offsetting.

          If there's an offset, please use the touch calibration tool under the WS4 tools tab.


          Best regards,
          Kayven

          Comment

          Working...
          X