tryphotino/photino.Samples

On contextmenus and page refresh

Opened this issue · 6 comments

I'm not sure where this goes, but this seems as good a repo as any.

I've only been playing around with photino for a few hours, but one of the first things I noticed was:

  • right click opens the browser context menu
  • context menu, F5, Ctrl+F5 or Ctrl+R allow refreshing the page

Of course this is all standard browser behavior, and you could say it's the developer's responsibility to deal with.
However, seeing as this is a framework for developing cross-platform stand-alone applications, it seems to me this behavior should be disabled by default .

I was playing around with the blazor template, and refreshing any page in this app results either in an eternal "Loading" message, or a "Page cannot be reached" browser warning.

This can all be disabled easily enough, but it seems to me you'd want to include this either in the templates, or maybe even straight in the framework through a config setting of some kind.

I used the following to disable context menus and page refresh:

In index.html:

<body oncontextmenu="return false;">
...
<script type="text/javascript">
  document.addEventListener('keydown', (e) => {
      e = e || window.event;
      if (e.keyCode == 116 || (e.ctrlKey && e.keyCode == 82)) {
          e.preventDefault();
      }
  });
</script>
...

@dimi3tron There is likely a way to do this in the native browser control. We will take a look and, if it's possible, we'll create a setting to enable/disable the dev menu. Thanks for the suggestion. We haven't seen this issue when refreshing Blazor pages. We will take a look. Our plans are to drop support for Blazor after the current version (1.1.x). .NET 6 and MAUI will have much better support for Blazor for Desktop than we could provide moving forward. That said, anyone in the community that would like to pick up support for Phhotno.Blazor is welcome and encouraged to maintain it.

With v2 the context menu can now be disabled.

We're also interested in being able to disable the refresh behavior for our app.

image
You can turn off the context menu. The TestBench sample shows how you can even toggle it from the web UI.

@MikeYeager - We've already disabled the context menu, but the ability to refresh via the keyboard remains. Should I open up a separate ticket specifically for that issue?

@ottodobretsberger - You mentioned disabling the key when we chatted this morning. Do you have an implementation you can point them to? Thx!