• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Button / modul

Scheduled Pinned Locked Moved Troubleshooting
12 Posts 3 Posters 5.7k Views 2 Watching
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.
  • M Offline
    Marko
    last edited by May 2, 2017, 12:51 PM

    Hi,

    i have add a button on magicmirror main screen. Problem is that i can’t start button (it is not interactive), i cant click on him. What i want to do is have button that can link me to some site or local path on pc. Is thare solution for this? Please help someone!

    Thank you,

    P.S. Michael, i just want to say that the project is great. Just ahead with development. Regards!

    1 Reply Last reply Reply Quote 0
    • R Offline
      romain
      last edited by May 2, 2017, 3:29 PM

      How did you add your button ? if you added it by using the document.createElement(“button”) from a js file, I beleive you can use the following syntax to add an action to it

      var newButton = document.createElement("button");
      
      newButton.addEventListener("click", function (event) {
         //your instructions here      
       });
      

      But in order to press it, I guess you would have to show your mouse right ? or maybe you have a touchscreen.

      1 Reply Last reply Reply Quote 0
      • M Offline
        Marko
        last edited by May 3, 2017, 7:43 AM

        Thank you for help,

        but i didn’t get the click in function, i tray to add it like my own module and put it in index.html, but both doesn’t work. I have it on screen but it is not operational, in my test html it works. I remove hidden mouse cursor in css, so i can move it ower screen for testing but it will fit behind touchscreen. I’m begginer in javascript, so this is my first time meet with node and electron. Is modul requires certain writing rules to be active?

        Thank you

        R 1 Reply Last reply May 3, 2017, 7:51 AM Reply Quote 0
        • R Offline
          romain @Marko
          last edited by May 3, 2017, 7:51 AM

          @Marko Can you copy past what you did exactly ?

          1 Reply Last reply Reply Quote 0
          • M Offline
            Marko
            last edited by May 3, 2017, 7:55 AM

            No problem,

            i add this in head in html:```
            function myFunction() {
            var newButton = “Click me!”;
            var result = newButton.link(“https://www.google.com”);
            document.getElementById(“btn”).innerHTML = result;
            }

            This works great in my html file. 
            
            Thank you Romain
            B 1 Reply Last reply May 3, 2017, 8:24 AM Reply Quote 0
            • B Offline
              broberg Project Sponsor @Marko
              last edited by May 3, 2017, 8:24 AM

              @Marko it’s better if you don’t alter the index.html file and instead write a module to display the button. Use the default hello world module as a base.

              M 1 Reply Last reply May 3, 2017, 9:25 AM Reply Quote 0
              • M Offline
                Marko @broberg
                last edited by May 3, 2017, 9:25 AM

                @broberg i modify helloworld just like you sead, but still not active. Is thare function that can call it?
                Thank you again! ```
                //your code here

                 	getDom: function() {
                		var wrapper = document.createElement("a");
                		wrapper.innerHTML = "<a href="https://www.google.hr">" + this.config.text + "</a>";
                		return wrapper;
                	}
                });
                B 1 Reply Last reply May 3, 2017, 9:31 AM Reply Quote 0
                • B Offline
                  broberg Project Sponsor @Marko
                  last edited by broberg May 3, 2017, 9:32 AM May 3, 2017, 9:31 AM

                  @Marko well, you really can’t open links in that manner inside the MM, either you have to open a seperate browser or maybe if it’s possible to run google within an iframe (can’t remember the latest verdict on this subject).

                  And, what version of the mirror are you running?

                  M 1 Reply Last reply May 3, 2017, 9:37 AM Reply Quote 0
                  • M Offline
                    Marko @broberg
                    last edited by May 3, 2017, 9:37 AM

                    @broberg i’m running MM ver. 2.1.0 on Win 10 and Node.js 7.9.0 installed

                    B 1 Reply Last reply May 3, 2017, 11:13 AM Reply Quote 0
                    • B Offline
                      broberg Project Sponsor @Marko
                      last edited by broberg May 3, 2017, 11:18 AM May 3, 2017, 11:13 AM

                      @Marko aahh okey. To be able to click on anything on the 2.1.0 and prevoius versions you need to change the fullcreen region property.

                      So either update to 2.1.1 or add

                      
                      .region.fullscreen {
                        pointer-events: none;
                      }
                      .region.fullscreen * {
                        pointer-events: auto;
                      }
                      

                      To your custom.css file

                      M 1 Reply Last reply May 3, 2017, 11:57 AM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        3/12
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy