Announcement

Collapse
No announcement yet.

gen4-ulcd-70dct multipage app touch detection returns all images and static text

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

  • gen4-ulcd-70dct multipage app touch detection returns all images and static text

    I have a multi-screen app that uses touch detection.
    I am writing out the id that is returned by img_Touched(hndl, -1); and the result is very confusing.

    I get the ids of images and static text fields (ids as per <project>.aux file).
    Trying to address the issue, I have created a method for each form to initialize and implicitly disable these items with
    img_SetAttributes(hndl, ref, I_TOUCH_DISABLE);
    but this hasn't changed anything.

    So a couple of question in my request for help:
    1. Why is img_Touched returning elements that are not touch enabled?
    2. Iterating over all of these elements is prohibitive. Is there not a way to set touch detection only on elements that should have it?

    For reference, I did read https://forum.4dsystems.com.au/node/44735 and https://4dsystems.com.au/blog/4D-AN-00071/, so I am aware of the overlapping issue but that should not be the case for non-interactive elements like statictext.

    Please help.

  • #2
    I've created a much simpler app (attached) that demonstrates the issue. The workaround to make the button on the main form touchable is to uncomment lines 152, 161, 188 and 197.

    Note, to experience my frustration, try uncommenting only lines 152 and 161 to disable touch on the splash image (which shouldn't be even be touch enabled). The static text that has never been rendered/drawn still intercepts the touch!?

    In a project with hundreds of images and static text (and other non-interative elements) on multiple forms/pages, you can see why this is a huge problem.

    Surely there is a more sustainable fix than what I've done?
    Attached Files

    Comment


    • #3
      Hi,

      Welcome to the forum.
      1. Why is img_Touched returning elements that are not touch enabled?
      You have enabled the touch of the screen using touch_Set(TOUCH_ENABLED);. In this case, all of the objects will respond when you are using: img_Touched(hndl, -1); You could, however, explicitly disable the touch of the widget using the command:
      Code:
      img_SetAttributes(hndl, ref, I_TOUCH_DISABLE);
      or to disable all the widget:
      Code:
      img_SetAttributes(hndl, ALL, I_TOUCH_DISABLE);
      2. Iterating over all of these elements is prohibitive. Is there not a way to set touch detection only on elements that should have it?
      You could follow the instructions above. As a note: Before you switch to the next form, ensure that the previous objects are cleared and the touch for all of the widgets has been disabled.

      I've created a much simpler app (attached) that demonstrates the issue.
      Please try the modified version of your project, that should make it simpler.
      Let me know if you encounter any issues.

      I hope this helps.

      Best Regards,
      Kevin
      Attached Files

      Comment


      • #4
        Perfect, this function was all I needed.
        Code:
        func Clear_and_DisableTouch()
          // Before you switch to the next form, ensure that the previous objects
          // are cleared and touch has been disabled.
          gfx_Cls(); //clear screen
          img_SetAttributes(hndl, ALL, I_TOUCH_DISABLE); // disable touch
        endfunc
        It does seem like strange behaviour since, in the code pasted by Worshop4 it explicitly calls img_ClearAttributes(hndl, ref, I_TOUCH_DISABLE); to enable touch. It is a bit misleading since touch_Set(TOUCH_ENABLED); apparently does that anyway but on a much larger scale.

        Thank you for your help.

        Comment


        • #5
          Hi,

          Thank you for your reply.

          Perfect, this function was all I needed.
          I am glad that it works for you.

          It does seem like strange behaviour since, in the code pasted by Worshop4 it explicitly calls img_ClearAttributes(hndl, ref, I_TOUCH_DISABLE); to enable touch. It is a bit misleading since touch_Set(TOUCH_ENABLED); apparently does that anyway but on a much larger scale.
          The function img_ClearAttributes(hndl, ref, I_TOUCH_DISABLE) enables the touch functionality of the widget. Specifically, after disabling the other widget's touch functionality, you still need to use this one.

          Have a good day!

          Best Regards,
          Kevin

          Comment

          Working...
          X