Can't receive WM_MOUSEWHEEL event in npapi windowless plugin - npapi

I've written a windowless NPAPI plugin and I want to handle mouse events in NPP_HandleEvent().
I can get WM_PAINT, WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE event without any problem.
However, it's wired that I can't receive any WM_MOUSEWHEEL event.
uint16_t CWinLessPlugin::HandleEvent(void *event)
{
NPEvent *pevent = (NPEvent *) event;
switch (pevent->event)
{
case WM_PAINT:
break;
case WM_MOUSEMOVE:
HandleIt();
break;
case WM_MOUSEWHEEL:
//never
break;
}
return 1;
}
I really can't figure out why :(. Any help will be very appreciated.
chrome version : 31.0.1650.63
firefox version : 25.0.1

WM_MOUSEWHEEL is not included in the list of (supported) events in the documentation. Firefox definitely doesn't support it [1] [2], Chrome probably doesn't either.

I reported that as a bug in firefox, let's see if mouse wheel event will be supported in a browser post 2014.
link:
https://bugzilla.mozilla.org/show_bug.cgi?id=1057972

Related

Listen for gamepad button events with xbox one controller

I'd like to listen for button press events on an xbox one controller, but seems that many solutions to this are experimental and under development. Most examples I've found showing how to receive input from a gamepad use a polling method to repeatedly check the gamepad for events, but for my application it is crucial that I can record the exact timing of the button press, and I don't want to miss button presses in between scanning the game pad.
I can use either Firefox or Chrome but I haven't gotten the following solutions to work in either browser yet:
Firefox: According to this page https://www.chromestatus.com/feature/5989275208253440#, "gamepad button and axis events are implemented in Firefox behind the flag dom.gamepad.non_standard_events.enabled". I have enabled this in Firefox but listening to state change events (as described at https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/) still has no effect.
Chrome: This github page https://github.com/MozillaReality/gamepad-plus/blob/master/README.md looks like it can extend the Gamepad API so I can also listen for button press events in Chrome, but when I try to compile the JavaScript as a standalone module using npm run build I get the error node_modules_missing and the build fails.
I'd appreciate advice on how to enable .addEventListener('gamepadbuttondown'... to work in either of these browsers.
Thanks to a codepen example by Christopher Van Wiemeersch at https://codepen.io/cvan/pen/aOzgGE I have found a solution in Firefox.
First I opened a Firefox browser (version 73.0.1) and entered about:config in the URL. Then I toggled dom.gamepad.non_standard_events.enabled to true.
Then I used the following functions/listeners from Christopher's codepen:
var gamepadConnected = function (e) {
console.log('Gamepad connected at index %d: %s. %d buttons, %d axes.',
e.gamepad.index, e.gamepad.id, e.gamepad.buttons.length, e.gamepad.axes.length);
};
var gamepadDisconnected = function (e) {
console.log('Gamepad removed at index %d: %s.', e.gamepad.index, e.gamepad.id);
};
var gamepadButtonDown = function (e) {
console.log('Gamepad button down at index %d: %s. Button: %d.',
e.gamepad.index, e.gamepad.id, e.button);
};
var gamepadButtonUp = function (e) {
console.log('Gamepad button up at index %d: %s. Button: %d.',
e.gamepad.index, e.gamepad.id, e.button);
};
window.addEventListener('gamepadconnected', gamepadConnected);
window.addEventListener('gamepaddisconnected', gamepadDisconnected);
window.addEventListener('gamepadbuttondown', gamepadButtonDown);
window.addEventListener('gamepadbuttonup', gamepadButtonUp);
Then when a button is pressed I record the timestamp using var timestamp = new Date().getTime().

HTML5 drag-drop between different browsers and apps

Browser quirks aside, HTML5 drag and drop works between different windows of the same browser. When I run up the web app in different browsers, I still get the dragover events but the data is missing.
Here are the the dragStart and dragOver handlers. Not very interesting, they just implement what MDN tells you to do. The code is Typescript.
public dragStart(e: DragEvent): boolean {
e.dataTransfer.setData("text/json", JSON.stringify(this.Model));
return true;
}
public dragOver(e: DragEvent): boolean {
if (e.dataTransfer.items.length) {
let raw = e.dataTransfer.items[0];
if (raw && raw.type === "text/json") {
//highlight drop target
}
return false;
}
return true;
}
This code running in two Chrome windows, it works - I can drag between the windows. This code running in two Firefox windows, it works.
Chrome to Firefox, or Firefox to Chrome, I get events but no data.
Why and what can I do about this? And if it cannot be made to work, what's the point of firing drag events for drag from another app if you (Google, Mozilla etc) aren't going to surface the data?
This probably isn't the end of the world for copying from one browser app to another; a given user will more than likely use the same browser for both. But I had visions of interop with desktop applications, and this does not bode well.
When I change the "mime type" used with setData and getData from text/json (which is what the data is) to text/plain, suddenly it works between Firefox and Chrome, and I can also drag a node to a text editor, where unsurprisingly the JSON is inserted as text.
And it works with Edge now. Crikey, according to mdn you can make up your own values. They left out "but not if you want interop with another app"
I had thought to use the type to decide whether to allow drop, and text/plain does little to help me wit that. I can try a parse and if that succeeds I can check some attributes, but this is rather heavyweight, and according to Drag'n'drop dataTransfer.getData empty it won't work anyhow.

WP8 : IExplorer 10 : on "keyup" event not firing for "RETURN" key

I've just came across this interesting problem, or probably it's just me missing something very basic (hopefully). The problem is, that the keyup event is not firing for the return key in the WP8 browser, whereas all the other standard keys are firing this event up.
I've tested this on the desktop, and IE10 is not having any issues with this, the event fires up nicely.
Can anyone else confirm that on their WP8 devices the keyup event is not being triggered for the "return" key ?
/using dojo syntax here/
on(dom.byId("testinput1"), "keyup", function(evt){
dom.byId("result1").innerHTML = "";
if (evt.keyCode == keys.ENTER)
dom.byId("result1").innerHTML = "ENTER pressed.";
});
Here is the jsfiddle link
open it in IE10 -> no problem for both of the input boxes
open it in WP8 browser (IE10) -> the first input box wont trigger keyup for the return key
Thanks for all your help.

trigger dom-level events

Does anyone know of a method to trigger a click on an element with mootools at the dom level?
foo.fireEvent('click') will, for instance, only fire events added by mootools, which is not very helpful for this particular application.
Here's a fiddle with a toy example - you can see that clicking the top button will fire off both event handler functions, while trying to use the lower button to trigger a click will only fire off the 2nd function.
http://jsfiddle.net/Tc4Bv/
Any help would be appreciated - thanks!
modern browsers have an Element.click method available, so you could try something like this:
Element.implement({
synteticClick: function() {
var click = 'click';
(this[click] && !(this[click]())) || this.dispatchEvent(new Event(click));
return this;
}
});
http://jsfiddle.net/dimitar/LUPYK/
works/tested in latest FF, Chrome, also IE9 and IE9 in IE7 mode (compat).
keep in mind that the event object may be basic, i.e. lacking clientX/Y etc - so it very much depends on what you do at the other side...

How to execute a script in chrome extension? when the content is changed?

I want to execute a chrome script,when the content of webpage is update (E.g like Facebook)
So what method I should use for that?
You can use
$("body").bind("DOMSubtreeModified", function() {
alert("something changed");
});
Note: DOMSubtreeModified is deprecated
You should try it with chrome.* API:
chrome.tabs.onUpdated.addListener(
function(integer tabId, object changeInfo, Tab tab) {
//your code
});
See here for documentation:
http://code.google.com/chrome/extensions/tabs.html#event-onUpdated
It should work for updates like (AJAX) requests etc...
As sachleen said, you can use DOMSubtreeModified listener
document.addEventListener("DOMSubtreeModified", methodToRun);
Note that the Mutation Events are performance hogs which can't really be tamed well (they fire too often and slow down the page a lot). Therefore, they have been deprecated over a year ago and should be used only when really needed. However, they work.
If you want this for a Chrome extension, you could use the new and shiny Mutation Observers from DOM Level 4 (follow the links there, they explain a lot!). Where DOMSubtreeModified fired a thousand times, MutationObserver fires only once with all the modifications contained and accessible.
Works for (as of 2012/06):
Chrome 18+ (prefixed, window.WebKitMutationObserver)
Firefox 14+ (unprefixed)
WebKit nightlies