How to listen for clipboard events in TideSDK? - tidesdk

I want to listen for clipboard events (when something is copied), and then grab a copy for processing.
I can't seem to find an event for this within TideSDK. Even if I could, would this be triggered if the app isn't in focus?

Related

Detecting browser tab closure in Bokeh

I want to detect if the user closes the browser tab that my application is running in. If this happens, I want to shut down a connected physical device. I'd like the sequence of events to be: user closes the browser tab (or browser), callback function is triggered, callback function closes device.
I'm using the Bokeh Server to serve an application. I don't use CustomJS at all.
Ideally, I'm looking for some kind of callback function (something like on_browser_close). I can't find anything in document or session that might do.
Is there a way of detecting that the browser (tab) has been closed?
I think you want to make use of on_session_destroyed, which is described in Lifecycle Callbacks. In a "Directory Format" Bokeh application, add a module server_lifecyle.py:
# server_lifecyle.py
def on_session_destroyed(session_context):
# called when a session is closed (e.g. tab closed or time out)

Detecting browser window close event in flex?

Is it possible to detect in Flex application browser window close event so that an action can be
started when user closes Flex application, does anyone know how to do that if it's possible in the
first place? The reason why i am asking this is because i have a multiuser Flex application where
every user has it's own directory on a server side. Application has logout button which triggers
cleanup of user's directory but what if the user just closes the window? I would like to be able
to lunch that same cleanup upon browser close window
In the page hosting your app, write a Javascript function triggered by window.onbeforeunload, and this function can call a function inside your Flex application.
Note that the onbeforeunload function is not guaranteed to work for all browsers.
I would not recommend that approach because the closing action fails too often, meaning worthless. My browser freezes and force-quitted several times a day. My computer sometimes freezes. My internet connection sometimes dies. I think, some browsers even do not guarantee those kinds of actions executed every time.
So, the session timeout might be one safe way in most cases.
You can also try having a socket connection, so that your server can ping if a user is alive and also can detect if socket is closed. Even socket, however, can be unresponsive or can be disconnected sometimes while user is still using the application.
You might want to be strategic.

How to fileRef.download(request) programmatically

I am able to download a file from my server when a user clicks a button in the on clicked event handler, but I have to first create the file on the server with a service call. In my on success method I can then download the file for the user. When I do this, however, I get the following error
Error: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
I think I understand the error in that the download pop up window can only be invoked from a user interaction. How can I work around this. I am doing it in response to a user interaction, but I cannot execute the download until after the server has created the file.
The reason that functionality is there is for security purposes. I would say there is no way to "Get around this"; but you can consider alternate implementations. Here are a few:
1) Give the user an interface. The first button click says "preparing file for download" and the when you get the resource back; change the button to "download now". That way you force user interaction for the download.
2) Immediately launch a URL to the server side template that will generate the file and return it. If the process is relatively quick the user probably won't care.
3) Switch to an AIR app which does not include as many restrictions in access to the local file system.

cancel asynch postback with lengthy server process

I'm having a bit of trouble cancelling an asynch postback. I have an update panel with an update progress which contains a cancel button so that the user can cancel the postback. When the user clicks a button to generate a report the update progress is shown. The report can take a bit of time as it has to loop through a thousand or so times creating an excel spreadsheet. If the user decides to cancel running the report for any reason then they can click the cancel button which I then call abortPostBack() in javascript which stops the update progress and the page is shown again. However, the user can't do anything else like navigate to another page as the server is still processing the loop. How would I stop the loop on the server processing when the user has clicked the cancel button? Any help appreciated!
Are you saying that a simple HTTP link is not accessible on the client side until the async postback is complete? If so, that sounds like a conundrum, since you either have to optimize your server side process, or set a smaller server-side request timeout. Either that or redesign your user-interaction to make the server side Excel generation process an asynchronous one, rather than synchronous, so that the user doesn't have to wait until the Excel generation is complete. You could fancy this up on the client side to then set a JavaScript timer to periodically query the server to see if the file was ready, and if so, indicate that to the user with and give them a download file link option, or something.
Otherwise, if you could invoke another AJAX request while waiting on that to return (which you may not to from the sound of it), you could simply perform a new HTTP request that "cancels" the long running process. But that seems like it would not work since the server is still handling the long running HTTP request. So I'd opt to investigate the options in my first paragraph.
If cancelling did allow an async HTTP request to be performed on the client side, then you could set a session state value to indicate that cancel was requested. Personally I wouldn't approach it this way. But if you did, then your long-running server-side process could periodically look for the existence of a session value. Say:
if (Session["cancel-me"] != null)
{
Session["cancel-me"] = null;
abortThisLongProcess();
}
Yep, even if you navigate away from the page using the browser back button, as soon as you click anything else that needs to post back to the server the page hangs until the long process has completed. Looks like there's no way of canceling so I will have to look at redesigning the Excel generation.
I haven't found a way to cancel the request that's running, but there's no real reason that you can't start a new one.
By default ASP.Net tries (it can't always) to apply an exclusive lock on the session object - as soon as one page reads it every other page request that passes the same session ID (by cookie or on the URL) has to wait for the first page to release the session.
It doesn't matter that the client has cancelled the request - the server will continue to lock the session until the original page finishes executing.
I think the solution is to do away with the ASP session entirely. Then when the user requests another page it begins immediately, even though the server is still processing the old request on another thread.

URLLoader cancel load on any browser event

I have a flash element in a page that load a chart based on some complex queries that can take up to a minute to load. I call the query with this code :
var chartData:URLLoader = new URLLoader();
chartData.addEventListener(Event.COMPLETE, onLoaded);
chartData.addEventListener("httpStatus", onHttpStatus);
chartData.load(new URLRequest(chartURL));
I listen for the complete event or any server error event.
My problem is when a user want to go on another page while the flash is loading the URL : the browser is waiting for the url to be fully loaded before accepting the request of the user. As I say this chart can take up to a minute to load and it's kind of annoying for my users to wait if they want to change page.
Here is my question : Is there is an event to listen any event from the browser (click on another link, click on the "back" button of the browser...) ? If I'm wrong in my way to do this don't hesitate to tell me, I'm not really used to program in flash.
Thank you.
I think I understand what you're describing. Some things you might want to try out:
File Upload HTTP Server
If the files are very large, you might want to load them on another HTTP server, like Nginx. Check out the Nginx Upload Module (I'm sure Apache has the same thing). That basically allows you to upload files without making the user feel the impact at all.
The only problem with this is that it's pretty complex, and you won't know when the file is done uploading. But they do have examples of how to show Upload Progress Bars with Nginx using Javascript, so you could do something like that, and on completion (in javascript), send a message to flash that invokes something like your Event.COMPLETE handler.
Browser Events
There are browser events to intercept with Javascript to prevent your user from leaving the page until the download has completed (not recommended as it may annoy the user):
onexit
onclose
onblur (when they click somewhere else)
Check out this example: Javascript onclose: Warn the User.
Hope that helps,
Lance

Resources