User Tim Down of the Stack Overflow forum provided a very simple Javascript code to clear selected text. This should work in all major browsers.

I recently added a notification feature for my widget and what I wanted was whenever the user clicks or taps the notification message in the notification center, it will remove itself rather than having to click the clear all button.

The secret lies in the flags of the Notification class by using Notification.FLAG_AUTO_CANCEL. However, to ensure that this works, the code has to be bitwise-or the flags like this

Pretty easy, right?

Related Posts Plugin for WordPress, Blogger...