Announcement

Collapse
No announcement yet.

User Button States

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

  • User Button States

    Hi,

    My user button needs to respond to three states based on the application which are:

    ON

    OFF

    DISABLED

    I've tried setting up the button's momentary property as: Both, No, On, Yes. But I can't seem to get it to do what I need.

    Ideally when the button is DISABLED it should be in a third state.

    This would be very easy to implement in the Genie environment. Simply create a new user button type where there are 3 bitmaps, The first one is off, the second on, the third disabled. If bitmap 3 is set programatically, just display the bitmap and ignore all touch screen inputs.

    If any one knows how to do this without 4D systems adding code please let me know. (although it'd be fairly simple for them to add since most the code exists for the current buttons)

    Thanks.
    Attached Files
    Last edited by Voodle; 24th May 2014, 01:47 AM.

  • #2
    Unfortunately it is not as easy as it seems, as you need to take into account the size that any program that uses it will grow (it's not simply one line of code) and the number of very large programs that are already out there.

    If your controller is receiving all button presses (eg 'Both' for momentary), then you can track the buttons state in your controller and immediately set the state to what you believe it should be when a touch occurs (i.e. if it's disabled, just reset the disable image)
    Mark

    Comment


    • #3
      Hi Mark,

      I have three images as per the first post. If I track the state of the button, and want to put it to the disabled state, the third image, it doesn't display and I get a red box with a cross. It appears I can't actually set the image to display in a user button.

      Comment


      • #4
        After more investigation it appears that by sending a user button a command to display an image is actually try to push the button, rather than change the image. Is this correct?

        Comment


        • #5
          I could solve this problem very easily by setting up a "button" as a series of user images. If the person touches an image then the PC could set the state of the image. Problem solved.

          However, a user image does not respond to a touch command, even though OnChanged is set to Report Message.

          Is there a bug in Visi-Genie or does this OnChanged for a user image do something else? When I change the image using GTX, the image changes, but I see no OnChange event fire which leaves me wondering what OnChange should actually do.

          Comment


          • #6
            As per the documentation, a user image is output only, so it cannot respond to a touch.
            OnChanged for it is for 'cascading' the on changed of an input object.

            I will try and do a quick example of how to use a user button to make it disabled.

            Maybe you should be doing this in ViSi?

            Mark

            Comment


            • #7
              Hi Mark,

              I'd have to learn the visi enrionment which will take time unfortunately and I'm deep in tens of thousands of lines of code on the PC which is where my attention needs to be. Visi-Genie is a great tool and does everything I need and allows me to forget about the UI code.

              Comment


              • #8
                Understand... Hmm, a working example is a bit hard (as GTX doesn't allow for the full flexibility of userbuttons), anyway here's what I did
                1. Create a User button with 5 images (image 0 is what Genie will display 'normally', image 1 is what Genie will display when image is touched, image 2 is 'on', image 3 is 'off', image 4 is 'disabled').
                2. Set momentary to Both.
                3. Set OnChanged to ReportMessage.

                In your controller you need to override whatever genie is setting the buttons to but commanding using 'Set UserButton' to 2, 3 or 4.
                So you might initially set it to 'on', when a 'Press' comes in you immediately issue 'Set UserButton' to make it 'on' (say), when 'Release' comes in you immediately issue 'Set UserButton' to make it 'off'.

                If it is disabled you set it to 'disabled' for both 'Press' and 'Release'.

                Hope that makes sense.

                You could also create 'on pressed' and 'off pressed', not no mention 'Disabled Pressed' images and show them at the appropriate places.
                Images 1 and 2 could be something 'non obvious' as they should only show for a brief instant.
                Mark

                Comment


                • #9
                  Hi Mark,

                  This appears to work, but with slightly more button state testing code at this end. Using the example images above, the only downside now is that there is a flash of the yellow button which is quite obvious.

                  How hard would it be to build in to Visi-Genie a ReportMessage when an image is pressed? If you're concerned about extra code given the RAM usage, perhaps make it another object and add it to the tool bar. It's just that I'd like to see a clean user interface on the display.

                  Thanks for your help so far.

                  Comment


                  • #10
                    Understand, I need to do some thinking about this to see if I can come up with a neat way to do it in a small piece of code
                    Mark

                    Comment


                    • #11
                      Thank you. It may be as simple as adding another type to: Both, No, On, Yes.

                      Perhaps just add 'none' but still have the object do a ReportMessage and don't update the bitmap. That'd be very easy and simple.

                      Comment


                      • #12
                        Hi again,

                        Or just have invisible screen zones that can sit over an object, like user images, that generate a ReportMessage Event. The suggestion above may be easy with the 'none' or 'user' setting.

                        Comment


                        • #13
                          I have attached a file that will mean that Momentary UserButtons are not visually update by Genie. So, you set type to Both and you will get a message for the Touch and the release, but the altering of the images (if desired) is up to you.

                          Unzip the file and replace the one in C:\Program Files (x86)\4D Labs\4D Workshop 4 IDE\Genie\DIABLO and the rebuild your project.

                          Note that when you command the use images to change the image that is displayed is actually the index * 2, eg if you say display index 3, the 6th image will be displayed. This is because, for buttons you can only command the 'up' states, but in this case that is not apparent.
                          Attached Files
                          Mark

                          Comment


                          • #14
                            Hi Mark,

                            Thanks, I'll give it a try. I'm assuming this will work with the Picaso controller as I'm using the uLCD-43PCT.

                            Comment


                            • #15
                              Sorry, no it won't, I thought it was Diablo you were using because it is in the Diablo forum. Here's the Picaso version.
                              Attached Files
                              Mark

                              Comment

                              Working...
                              X