🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    [Core2] make Button disappear

    Core 2
    1
    1
    3.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wa-berlin
      last edited by

      I seek for a solution for the following problem.

      The code below shows a button handling in Core2.
      When the Event is detected I want to get rid of the button, i.e. make the button disappear.
      I tried several options, see source code.
      What happens is, that the event is disabled.
      However when I push in the button area on the TFT the button appearance still behaves by changing colors.
      What do I miss here?
      Thank you in advance for any hints!

      #include <M5Core2.h>
      
      ButtonColors onCol = { TFT_DARKGREY, TFT_WHITE, TFT_WHITE };
      ButtonColors offCol = { TFT_WHITE, TFT_BLACK, TFT_WHITE };
      
      Button rt(162, 0, 158, 80, false, "120 sec", onCol, offCol);
      
      void RtBtnTouched(Event& e) {
              Serial.println("Touched!");
      		// deactivate button --> three approaches tested so far	   
      		rt.delHandlers(RtBtnTouched); 
      		rt.hide();
      		~rt;		
      }
      
      void setup() {
      	M5.begin();
      	rt.addHandler(RtBtnTouched, E_TOUCH);
      	rt.draw();
      }
      
      void loop() {
      	M5.update();
      }
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post