How to capture paste event from right-click context menu? - asp.net

I have a textbox in ASP.NET web form, and I need to catch the paste event from right-click context menu. But I can't see where I can catch the associated event.
The onchange event is no use, as this is only triggered when the input field loses focus. Neither does OnKeyDown event since it is not a mouse event.
Any solution?

It is a common problem to which exists no good solution.
There is no cross-browser way to capture mouse paste event.
People are getting away with running a timer to detect any change soon after it's happened and then to react to it.

There is the paste event in some but not all browsers. IE has had it since version 4 or 5, I think, as well as beforepaste. Firefox I think got the paste event from version 3.0, and recent versions of WebKit have it (Chrome and Safari 4 have it at least), don't know about Opera. You'd have to research the specifics such as precisely which browsers support it and which element raise the event, but I would say it's still not widely enough supported to use on the general web.

Related

Internet Explorer currently state test

I saw similar problems to my problem, but I have not seen useful solutions for my issue.
Situation:
When I play a video file within firefox, I can see current state of html-markup (F12) because of that I can trigger some funtions in my php behat/mink code.
The same situation occurs in IE, and I dont see current state of my markup-code and I canĀ“t trigger my test-functions.
Example:
Firefox opens modal dialog and it appears by markup (F12) css class "open window"
IE opens modal dialog and it not appears by markup (F12) css clas "open window"
How can I detect current markup state in IE, when I can look only at markup?
UPDATE
Here is my code. I just looking for one css-selector, but it does not working
on IE10
$node = $this->getSession()->getPage()->find('css', $css_selector);
Problem beginns by IE10:
When i press F12 within IE10, i will see developertools.
I see within "HTML-section" current state of html-markup.
I click on icon and modal dialog appears.
Actually my html-markup changes after that. Some css classes come additionaly to video-tag.
I have to click by developertools on "refresh"-Button or F5 to see
currently markup-state, which contains modal-dialog.
To achieve same effekt whithin behat, i use:
$this->getSession()->reload();
That does not work. Behat can not find new css classes, which referes on modal-dialog.
Please look on picture:
I hope, it is clear now, what i mean :)
As i understood, for IE the class that you are using in the validation is not added and you are not able to check that the modal is opened.
As an alternative you could use alternative methods to verify that the modal is opened and to avoid cross-browser issues like this.
I think is better to work with what you already have without reloading or doing any actions that could lead to extra code that could affect other browser or could affect the stability of the scenario.
One way of doing this is to check that the modal is visible using isVisible() method.

find key presses from layout controls (not entry field) in xamarin.forms

I need to find what key the user pressed on a keyboard using xamarin.forms, ideally inside an AbsoluteLayout. I've come up with a few ways myself, but can't get any of them working.
As there isn't an event for this on the AbsoluteLayout control, i tried a little cheat, which was putting an entry field (textbox) on the screen, but hiding it above, so it can't be seen and using the result from that, but it loses focus when someone presses the screen or a button on the screen. so i tried adding an event to each button which refocuses the textbox once i've handled the press and this seemed ok at first, however, if they press anywhere else on the screen, it also loses focus.
I also tried adding a TapGestureRecognizer to the screen, and focusing the button when they press anywhere on the screen, however, there were 2 issues with this, the first being that it appears to only fire when something inside it is touched, and secondly, when i call the focus method for the second time (if they click the screen twice) it un-focuses the entry field, even if i check "isfocused" first (think this is a bug).
I'm only concerned about windows 8 and android apps so far. iOS may come later, but for now im just trying to get it working for these OS's. so maybe i could code it in the windows and android projects (inside my shared project solution), however, i have absolutely no idea where to even begin doing that. I mean, if this is the best way, how can i pass my AbsoluteLayout to the windows project and get it to know what it is, and convert it into a control which i can then add the event to.
Any help or advice, or ideas would be much appreciated. I cant find anything in NuGet which will help me with this. Any ideas?
Many thanks
James

Giving a Flex application the focus in browser to capture keystrokes

I've written a little video game in Flex that runs in a browser. The player moves by pushing the arrow buttons on the keyboard, so I need to capture those keystrokes. In fact, the game action starts when the player presses one of those keys.
In order to capture the keystrokes, the Flash/Flex application, not just the browser, needs to have the focus.
How can I ensure that the application has the focus? I've implemented a bit of a hack: A "Begin" button you must click to start the game. The only point of this button is to ensure that the app has the focus. Is there a better solution to this?
No, this is the only way, but I think your present solution is a great one. The reason that you (as a user) have to click to focus, is so that the application cannot quietly steal focus, to then log the keystrokes without your knowledge, e.g. to steal passwords.
In some browsers (IE) you can give a SWF focus via JavaScript. Unfortunately this doesn't work in Firefox. So some users will have to click on the SWF to give it focus. You could pretty easily in your game check the browser and if it's IE then give the SWF focus automatically and not show the "Begin" button. Then in Firefox show the "Begin" button.
Take a look at the link below. Worked well for me.
http://www.flexjunk.com/2010/12/30/managing-initial-swf-focus-in-all-browsers/

Capture hotkey in browsers

I'm doing SWF application which will run in browser.
And I want to capture CTRL+F key pressing event when Flex application is in focus.
In Firefox it works fine but in Opera and Safari browser captures event prior to Flex application and Find Dialog pop-ups.
Is there any way for flex application to capture CTRL+F event prior browser?
I asked this same question recently and have been playing around with it.
I came up with this gist on github:
Browser KeyboardEvent Hijacking with Javascript and Flex
CTRL-F works!
Check out the javascript in there. Basically, with Safari, you can only hear the meta keys (ctrl/alt/shift, etc.); it won't allow javascript to hear A-Z events if Flash is running for some reason. So I just listen for the meta keys in javascript, and then call window.focus() in javascript. That sets focus to the browser, making it so you can hijack browser keyboard events!. Then I listen for the A-Z events or whatever, and pass those to Flex.
The next step is to just restore focus in your Flex app to wherever it was before that, which should be easy.
Cheers,
Lance
Maybe add javascript to your html containing the swf that would block it. It sounds like those browsers process events in a different order so I doubt there would be anything you can do from within the flash player that would do it.
Where e is a keyboard event:
if(e.commandKey || e.ctrlKey){
switch(e.keyCode){
case Keyboard.N:
// do stuff
break;
}
}

Keyboard fails in IE8 after AJAX call

I've run into a strange problem with an HTML form. I've built a dynamic table that adds a new row when you enter data into an existing blank row; because there are some server requirements in adding a row, I make an AJAX call to do this in the onblur event. It took a while to make this work for all browsers, but eventually all was happy with the world ... until IE8. Now, what happens is that, when the call returns from AJAX, the cursor shows in the next textbox (correctly), but the keyboard no longer works. I have to close the modal window (actually an IFRAME), then the keyboard starts to work again. If I put IE8 into compatibility mode, it works fine.
Has anybody seen behavior like this, or have any ideas for a workaround?
Thanks, Jim
I had problems with DIVs placed above an INPUT, that cloacked the cursor... and once the DIV was not above it, the cursor appeared back again.
Just an idea: Maybe your IFRAME captured the focus (and/or the keyboard).

Resources