Announcement

Collapse
No announcement yet.

User Button as index changer for UserImage control

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

  • User Button as index changer for UserImage control

    Hello,

    I'm having a very strange issue with a Genie project and I'm not sure if the issue is with Workshop4 PRO or something in my layout. I'm using a Gen4 43DT display and Windows 10.

    I have a Genie project with about 9 forms. On two of the forms, I have two user buttons set up as increment and decrement buttons. These buttons have their OnChanged handlers set to 'UserImagesNext' and 'UserImagesPrevious and are linked to a user image control. So when a user increments up or down, a set of four user images cycles up or down. Also, the user image is set up to Report a Message whenever its index is changed. Simple enough.

    This works perfectly on one of the forms.

    On the second form, the identical user button and user image linkage doesn't work. I've made sure that the user button OnChanged events are tied to the user image for the second form. I've made sure that the user image control for the second form is set up to report a message when its index changed.

    I've used the GTX tool to examine what's happening. On the working form, the user buttons report the proper image index (0 to 3) in the parameter value field of the return message.

    On the non-working form, the user buttons always report 0 in the parameter value field and the user image never changes as it should. However, I can manually "set" the user image to different indexes in the GTX tool.

    What could explain this?

    rgds,

    Gary

  • #2
    Hi Gary,

    Welcome to the forum!

    That seems to be a bit weird. Can you attach here your program so we can test it on our end?

    Best Regards,
    Kevin

    Comment


    • #3
      Originally posted by John Kevin View Post
      Hi Gary,

      Welcome to the forum!

      That seems to be a bit weird. Can you attach here your program so we can test it on our end?

      Best Regards,
      Kevin
      Thanks for the reply Kevin!

      Attached is the project.

      The project file I'm using is "OR8000Demo.4DGenieBK1.4DGenie"

      The form with the non-working linkage is Form1. The plus and minus buttons are user buttons 9 and 10. They are linked to user image 13.

      The form that operates correctly is Form7. The plus and minus buttons are 47 and 48 on this form. They are linked to user image 15 and, again, this form works as expected.

      best rgds,

      Gary
      Attached Files

      Comment


      • #4
        Hi Gary,

        Thank you for the project files. I have observed the issue that you mentioned. I'll try to investigate further as to what is causing the issue.
        If I may suggest, you could manually toggle the "User Images" widget by adding a Genie Magic code on Touch Press/Touch Release routine.

        Perhaps, this may help.
        Code:
        if (ImageTouched == iUserbutton10 && frame < 3)
             frame+=1;
             img_SetWord(hndl, iUserimages13, IMAGE_INDEX, frame)  ;
             img_Show(hndl,iUserimages13) ;
        endif
        
        if (ImageTouched == iUserbutton9 && frame > 0)
             frame-=1;
             img_SetWord(hndl, iUserimages13, IMAGE_INDEX, frame)  ;
             img_Show(hndl,iUserimages13) ;
        endif
        Best Regards,
        Kevin

        Comment


        • #5
          Originally posted by John Kevin View Post
          Hi Gary,

          Thank you for the project files. I have observed the issue that you mentioned. I'll try to investigate further as to what is causing the issue.
          If I may suggest, you could manually toggle the "User Images" widget by adding a Genie Magic code on Touch Press/Touch Release routine.

          Perhaps, this may help.
          Code:
          if (ImageTouched == iUserbutton10 && frame < 3)
          frame+=1;
          img_SetWord(hndl, iUserimages13, IMAGE_INDEX, frame) ;
          img_Show(hndl,iUserimages13) ;
          endif
          
          if (ImageTouched == iUserbutton9 && frame > 0)
          frame-=1;
          img_SetWord(hndl, iUserimages13, IMAGE_INDEX, frame) ;
          img_Show(hndl,iUserimages13) ;
          endif
          Best Regards,
          Kevin
          Thanks for this code snippet. This works very well as an interim solution and correctly changes the user image. It would be very nice for the Genie report message being sent back to have the proper image index.

          rgds,

          Gary

          Comment


          • John Kevin
            John Kevin commented
            Editing a comment
            Hi Gary,

            The 'Report Message' for the UserImage comes from the 'Event' set on the UserButton. If you want to get the image index of the UserImage, you can use this command: serout(img_GetWord(hndl,iUserimages, IMAGE_INDEX)); This will send a char (image index) on the COM port.
        Working...
        X