Listening to 4th and 5th mouse buttons in Chrome apps (for browser navigation) - mouseevent

I have a Chrome packaged app with an embedded webview. There are buttons for history back and forth like in a browser, but I would like to listen for keyboard and mouse events too.
This snippets catches both ALT-arrow keys and multimedia buttons, but not the 4th and 5th mouse buttons which are normally used for browser navigation:
$("html").on("keydown mousedown mouseup", function (event, data) {
console.info(event);
});
How do I detect the mentioned mouse buttons?

Related

PySide2 Tear Off Tabs

The project is to have a main window GUI with tabs, and the ability to tear off tabs into their own floating main windows. Exactly like the Chrome browser I'm using right now (probably most/all browsers do this). Using Windows 10, Python 3.7.7, PySide2 5.15.0.
I'm looking at similar questions here and elsewhere that use the native C++. They all seem to have one thing in common: Picking up mouse events on the tab.
I can create a subclassed QTabWidget and do all the things that pick up mouse events, for instance, putting a "installEventFilter()" in the class' "__init__()", and an "eventFilter()" function. Or simply overriding the "event()" function. I can pick up all kinds of events, including mouse events, but not on the tabs. Click/move in the tab view, yes; click/move next to the existing tabs on the tab bar, yes; but click/move on the tabs themselves produces "Paint" events. This is correct, as the tab view must be repainted when the tab is selected. But I can't pick up a mouse event for use in the dragging techniques I see in the C++ code. I can't pick up the mouse event that results in the Paint event.
Apparently, in native C++, the mouse events can be intercepted before they get to the tabs. I'm not seeing a way to intercept mouse events on the tabs in PySide2.

which best event for touchscreen application?

I have developed an application using VB.NET that uses a touchscreen (it's a Point of Sales app). I have used button click events to execute the code like a normal Windows application. Is this correct way to do it, or should I use MouseUp and MouseDown events?
Using Click events is correct. On a touch screen, tapping a button will generate a Click event, just like it would if you clicked the button with a mouse.
P.S. You mention in the comments that sometimes the application hangs when you click a button. This is most likely caused by the code that responds to the Click event, and is not related to using a touch screen.
Just ran into an issue on our Touch POS app yesterday. The click event is fired twice in some cases on some monitors. It seems that different touchscreen monitors handle the click even differently and some have software to prevent it others do not. The specific issue was that our click event was being fired two times so clicking button "1" would result in "11" Only happened when using the touchscreen not the mouse. The first depress of the button would put "1" and then when you took your finger off the button another "1" would appear. If you debugged the click event it would only be fired 1 time and just put 1 in the field. If you took debug out it went back to 11.
Save yourself the headaches and use MOUSEUP.

Getting mouse move events in embedded Elm program in Chromium

Note: I am only seeing this behaviour in Chromium. In Firefox I get the mouse movement signals I expect when I mouse over the Elm app.
When I "embed" my Elm program instead of "fullscreen" it, it doesn't give me Mouse.position signals unless I click and drag the mouse in the div in which it is embedded. Even when I move my mouse over the div containing the Elm app, I don't get signals unless I click and drag.
My Elm code is copied directly from http://elm-lang.org/examples/mouse-position :
import Graphics.Element exposing (..)
import Mouse
main : Signal Element
main =
Signal.map show Mouse.position
My HTML is:
<div id="mousepos" style="display: inline-block;"></div>
<script src="mousepos.js"></script>
<script type="text/javascript">
var mousepos = document.getElementById( "mousepos" );
Elm.embed( Elm.Main, mousepos );
</script>
If I click and drag on the div, I see the numbers change, but if I just move my mouse around, they don't change (even if I've clicked once to give the canvas focus).
Am I doing something wrong?
Edit: emphasised I don't see mouse movement even when I move the mouse over the div containing the Elm app.
Edit 2: added note that I only see this in Chromium.
Mouse.position only listens to mouse movements on the top level DOM element making up your Elm app.
You can see this by looking at the source code where Mouse.position is tied to the listening event. It adds the listener to the Elm app DOM node only, not the whole page. Since you're doing Elm.embed(), your node is just the mousepos div, not the whole page.
If you want to respond to mouse positions on the entire page, you'll need to make a port which sends in global mouse position signals from Javascript.

do not have mouse tracking support in nw.js

I want to listen to mouseleave when mouse leave window and listen to mouseenter when mouse enter window。
$('.report').on('mouseenter', function(){
$(this).css('border', '1px solid red');
}).on('mouseleave', function(){
$(this).css('border', '0');
});
but when i move my mouse fast, events will be triggerd, but when i move slowly, nothing happend. (I tested it on windows 7)
In many apps, we have to know whether mouse is outside or inside the window. Like some notification window, when mouse leaves, the window will be closed. But this feature cannot be achieved at this moment
what should i do?

Using MediaElement in Windows Phone 8.1 app

I'm developing a Windows Phone 8.1 app that plays a video using the MediaElement control. I'm facing some problems for which I've not been able to find information. I've uploaded an example app here: https://mega.co.nz/#!s9sFiQDK!JDI9ar8qWqWIZ_Ot-Q8K8X0qfQ5YG7ATLAiHypOs5Ow
If a click the button in the default page, the app navigates to a second page that contains a MediaElement to play a video. My app is configured to be Portrait only, but I want the video to be displayed in Landscape. For this, I'm changing the screen orientation when clicking on the button and before navigating to the video page with this line: Windows.Graphics.Display.DisplayInformation.AutoRotationPreferences = Windows.Graphics.Display.DisplayOrientations.Landscape; The problem with this is that I can see in the app when the orientation is changing which looks ugly. How can I do to make the video display in landscape without having to change the orientation of the screen? I've seen in the Facebook app that when a video opens, the app does navigate to another page (or at least it seems so from the transition animation that I see) but even though, videos open and play in landscape, there is no screen rotation.
I want to hide the StatusBar before the page with the video is displayed. I've put this line statusBar.HideAsync(); in various places but regardless, I always see that the StatusBar is still hiding when the video is already visible and playing. Again, the Facebook app does hide the StatusBar before the video is shown in the screen.
When the video is playing, if I press and hold the back hardware button, the app is minimized. Now, if I click on its screenshot to go back to it, the app comes to the foreground, but the video is not playing anymore. If I tap on the video to see the video controls, I can see that the video progress line is moving, but the video is like frozen. If I pause the video and play it again, the video resumes. How do I do to make the video to continue to play when the app comes to the foreground? In the Facebook app when I do this, the app comes to the foreground, but the video page is closed and the app takes me to the timeline page. Is this the only way of doing it? If so, how do I detect that when the app comes to the foreground there is a video playing so I can close the page and navigate to the previous one.
If you always want the video page in landscape mode, you can call
Windows.Graphics.Display.DisplayInformation.AutoRotationPreferences = Windows.Graphics.Display.DisplayOrientations.Landscape;
in the page constructor, after InitializeComponent();
Calling
StatusBar.GetForCurrentView().HideAsync();
in the main page constructor is working fine for me.
I still have the same problem, I've tried different approaches, but I can't even get App.Resuming event (and unfortunately in Windows Phone 8.1 WinRT OnNavigatedTo is not triggered on app resuming).