Announcement

Collapse
No announcement yet.

Cycle through forms by touching the screen

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

  • Cycle through forms by touching the screen

    Hi,

    I am just getting started and have a 32DT and a Teensy 3.5.

    Trying to detect touch events in order to cycle through forms.
    The idea are that touching the screen to the right moves to the next form, touching to the left of the screen returns to previous form.

    After searching the forum I found a reference to use userbuttons.
    • First I tried to create a form that would never be displayed and created two buttons there but I couldn't get any events when displaying another form.
    • Then I tried to create two user buttons per form that would cover either the left and right area of the screen and register a "OnChanged" event with a handler "Report Message" . This works but even though the buttons do not have any image or if I create a PNG with only a transparent color the button hides the content on the screen(so far only gauges added to the form).

    Is it possible to solve touch detection it this way or is there a better way via serial?
    If it is possible, how should the image be created in order to become transparent?

  • #2
    Hello,

    Welcome to the forum.

    For your reference, I have attached a simple project which uses a User Button to cycle through two forms. I have also added a background and the User Button did not cover any part of the screen. Please have a look, and if you have other inquiries, feel free to ask.
    UserButton with Background Image.zip

    Thanks and kind regards,
    Sherwin

    Comment


    • #3
      Many thanks Sherwin

      Your example works flawless. Unfortunate mine still doesn't and I have tried to look at all the settings and tried different combinations but every form is hidden by the userbutton.


      Attaching my code. Would be great if you could have a look and see if you can find what is wrong.

      Best regards
      Johan
      Attached Files

      Comment


      • #4
        Hello Johan,

        The root issue here seems to be fact that the generated code is prioritizing the Objects that are created first in the Form.

        To solve this issue, you could start from scratch and create the Forms first, and then create the UserButtons before creating any other object like Gauges.

        Or, if you want, you may open the *.4DGenie file inside your project folder using Notepad or any text editor that you prefer and edit/rearrange the objects from there. Please see screenshot below for your reference:
        Click image for larger version  Name:	rearrange.PNG Views:	1 Size:	19.6 KB ID:	70939
        As you can see, the UserButtons are just right under Form0 object. Rearranging the order of the objects/widgets should solve it. Please see attached project for your reference.

        I hope this helps.

        Good luck and kind regards,
        Sherwin
        Attached Files
        Last edited by sherwin4D; 14th January 2020, 08:05 AM.

        Comment


        • #5
          Many thanks Sherwin

          I rearranged according to your description.That fixed almost everything.
          All forms are now visible but on form 5 there are 3 red lines that still are gone/hidden.

          Could you have a look at that as well?

          Best regards
          Johan
          Attached Files

          Comment


          • #6
            Hi Johan,

            Sorry, I didn't take those 3 red lines into account. I've modified your project by replacing the 3 red lines with UserImages.

            Click image for larger version

Name:	screens.PNG
Views:	65
Size:	3.4 KB
ID:	70952

            You may adjust the images according to your preferred thickness and length.

            Kind regards,
            Sherwin

            Comment


            • #7
              Thanks Sherwin

              All tested and works perfectly.


              Care to explain the logic why it was not possible to use the built in Line obect? Are there more objects that I cannot use?

              Best regards
              Johan

              Comment


              • #8
                Hi Johan,

                I ran tests on my end and found that only Primitive objects are affected by this, e.g., lines, circles, etc.

                Primitive objects are not treated the same way as other regular Objects/Widgets like Buttons and LEDs for example, because they are part of the form background in ViSi-Genie. Hence, whether you created any primitive object first -- in your case, a line, before any other regular widget like UserButton, the priority would still be the button.

                I hope this satisfies your inquiry.

                Best regards,
                Sherwin

                Comment


                • #9
                  Thanks. Then I know.

                  Comment

                  Working...
                  X