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

    [Core2] make Button disappear

    Scheduled Pinned Locked Moved Core 2
    1 Posts 1 Posters 4.5k Views
    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 Offline
      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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post