locked
how to prevent the app bar from showing? RRS feed

  • Question

  • How do I prevent the app bar from showing? I have a html5 canvas that does other things on the right-click event, and it's stupid to see the app bar pops itself up every time.

    Is there something like,

    appBar.suppressShow();

    ?

    I tried to call the hide() method of the appBar but it does not work. I could go to the lengths of programming the appbar myself of course but it'd be better if there are some solutions here.

    Saturday, September 1, 2012 5:08 PM

Answers

  • There are two ways to do this.

    First, you can set the app bar's disabled property to true to suppress it for a right-click anywhere in the app:

    var appbar = document.getElementById("createAppBar");
    appbar.winControl.disabled = true;
    

    Second, if you want to disable it for a particular element, which is more of your case, then in your right-click handler (for the contextmenu event), call e.preventDefault();

    document.getElementById("output").addEventListener("contextmenu", function (e) {
        e.preventDefault();
    });

    I tested both methods in Scenario 1 of the HTML AppBar control sample, placing the code above in the ready method of the WinJS.UI.Pages control.

    .Kraig

    • Marked as answer by kayson Sunday, September 2, 2012 9:57 AM
    Sunday, September 2, 2012 3:48 AM

All replies

  • There are two ways to do this.

    First, you can set the app bar's disabled property to true to suppress it for a right-click anywhere in the app:

    var appbar = document.getElementById("createAppBar");
    appbar.winControl.disabled = true;
    

    Second, if you want to disable it for a particular element, which is more of your case, then in your right-click handler (for the contextmenu event), call e.preventDefault();

    document.getElementById("output").addEventListener("contextmenu", function (e) {
        e.preventDefault();
    });

    I tested both methods in Scenario 1 of the HTML AppBar control sample, placing the code above in the ready method of the WinJS.UI.Pages control.

    .Kraig

    • Marked as answer by kayson Sunday, September 2, 2012 9:57 AM
    Sunday, September 2, 2012 3:48 AM
  • That works beautifully. Thanks.
    Sunday, September 2, 2012 9:58 AM