No announcement yet.

Toggle Issues, Button Disappearing When Pressed

  • Filter
  • Time
  • Show
Clear All
new posts

  • Toggle Issues, Button Disappearing When Pressed

    Hello, in my project I am trying to make every single button a toggle to handle its appropriate function, but when I click my middle buttons (Quad 1, 2, etc.), I am shown a red blank image box during the toggle state. Is there any reason why my image is not loading on the up (Off) toggle state? Attached is the zip for the project.
    Attached Files

  • #2

    Apologies for the delay.

    I think it's because your buttons are set to 'momentary yes'. Please try to set your buttons to 'momentary no'.

    As you may know the red Xs means that your trying to display a frame that's non-existent. In your case, the buttons are set to momentary yes so they only have 2 to frames, up and down.

    I hope this helps.

    Best regards,
    Last edited by michael_4D; 3 April 2019, 04:51 PM.


    • #3
      Thank you for looking into this Michael. The toggle function in the example FancyButton code provided by 4DSystems performs the same way as the code I have. We are trying to recreate the toggle function in our program. During the touch release function, the button does not transition to its 2nd image. When you say 'momentary yes', does that mean we are in the 2 for 'on' up state, and 'momentary no' as 3 for 'on down' state?
      In the example code for the FancyButton, this is the state of the toggle button when released:
      if (n == iWinbutton1)
            if (Wbs1)                  // toggle status
              Wbs1 = 0 ;
              Wbs1 = 2 ;
            Display.img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, Wbs1); // where state is 0 for up, 1 for down, 2 for 'on' up and 3 for 'on' down
            Display.img_Show(hndl,iWinbutton1) ;
      where Wbs1 is initially 0, meaning it would disregard the if statement and execute Wbs1 = 2. Also, when Wbs1 = 2 statement occurs, when the program loops around again, will it take the if statement to become 0 again?


      • #4

        When you say 'momentary yes', does that mean we are in the 2 for 'on' up state, and 'momentary no' as 3 for 'on down' state?
        This has less to do with the coding and more to do with the images generated by Workshop4.

        Click image for larger version

Name:	Momentary.PNG
Views:	145
Size:	155.5 KB
ID:	67781

        A similar concept was discussed in this application note:

        ViSi Winbuttons

        The application note is made for the ViSi environment but it should still be relevant for you.

        Best regards,