I need to check for unsaved data when a packaged app is closed (using the close button at the bottom of the screen and then pressing the X that is top left when the app appears reduced size).
I've managed to add an event listener for the low battery condition and this works as expected. But looking at https://developer.mozilla.org/en-US/docs/Web/Events I can't decide which event is correct for closing an app.
The obvious name -- close -- seems to be something to do with web sockets.
mozbrowserclose seems to be triggered when closing by the app's software.
XUL close "the user presses the close button" seems like the appropriate one, but when trying
window.addEventListener("close", function( event )
{
window.alert("closing");
}, false);
the app closes without triggering the alert.
DOMWindowClose seems to be specific for close by window.close in software
mozbrowserclose seems to be specific to iframes
So ... does anybody know the correct event to trap ?
Phone is ZTE Open C with FFOS 1.3.
It looks like this is a bug -- https://bugzilla.mozilla.org/show_bug.cgi?id=996754 "User-terminated apps do not receive 'beforeunload' event"
Related
I have a very large accounting system. In a user preferences section, the program has begun to act abnormally on my development machine only. No customers are reporting this, nor can I duplicate it on any of my other computers. Running Windows 8.1, others are on 7.0. Not exactly sure when this started happening because it's not the kind of thing one goes into on a regular basis. The preferences screen consists of a tab control and various standard controls. At the bottom is Okay, Cancel, and Apply buttons. All three buttons seem to be acting with the same strange behaviour. Clicking with a mouse does not generate a click event yet does not hang the system - mouseup follows and you can click it again and see the mousedown and mouseup but no click. However, since the Okay is defined as Default, pressing enter DOES create the desired click event, and all the code inside that even runs fine. Cancel and Okay also unload the form, but when clicked, that doesn't happen because none of the code gets executed, yet you can still navigate the screen (move between tabs and controls) but you can't even click the "X" button to close the form at that point.
Also, if you go straight in, and press enter, everything works and the form unloads, but if you do anything before pressing enter (or escape to cancel), like change a tab and/or edit a value, then press enter, the click event again does not run and the system semi-hangs.
I tried turning-off my anti-virus thinking that might have something to do with it, but no-go. Debugging is frustrating because while I finally got it execute the click event, the stop command inside that event (after debug.print "click") would allow stepping and success if just straight in and enter, but if anything else done as before described would stop at the stop statement (keyboard enter only still no mouse clicks under any scenario) and would do a total lock-out. In other lockouts where it would let me navigate, almost always selecting a new tab would cause a fatal error and it would force-unload VB for me, otherwise I had to use the task manager.
This is driving me nuts, but I don't know how else to debug it.
The culprit was tv_w32.dll which is Team Viewer. Turning-off Team Viewer allows my program to run normally.
I'm a new Mac programmer writing my first mac app, actually porting an existing iOS app to MAC.
The app does a lot of remote communication, so when the user kicks off an operation, I want to display a busy window (or message box, or NSAlert maybe), until the operation is completed, then dismiss it programmatically, or the user can click cancel to stop it.
The busy window prevents the user from doing anything until that operation is completed.
The busy window should have a progress spinner, some text, and a cancel button.
Its such a simple thing yet I'm having problems with it because I dont really know MAC programming, getting myself frustrated.
Can anybody offer suggestions, or already written code for it. I hope some code for this already exists because I cant believe I'm the only person in the world who needs things kind of busy window.
Thanks for any help.
You mean something like this:
http://www.developers-life.com/example-nspanel-with-nsprogressindicator.html
???
Source code is available, too (link at the end of the article).
You can just modify the NSPanel in Xcode and add a "Cancel" button that you connect to your cancel action.
I am trying to prevent the user from closing the window when they click on the close button. I would like to have the application dock to the system tray.
My first step is to recognize when the user attempts to close the window and prevent the default behavior on that event. I would expect this code to work, but it does not.
var appWindow = Titanium.UI.getCurrentWindow();
appWindow.addEventListener('app.exit', function(event){
event.preventDefault();
})
I tried using the exit event and the event constants themselves to no avail.
This wont work because all your doing when you call preventDefault is stopping the default behavior in the WebKit browser page, not the native application wrapper itself.
The close command is a native function call to the underlying wrapper, it just passes an event to the listener, it does not pass control.
Also, this sounds somewhat dangerous, not allowing a user to close an application seems problematic. Maybe instead you should register a background service to run instead?
one trick might be to open an 'invisible' window for the app, so even if the user closes the 'application' window, the app should still be running.
I am facing some issues in WP7 tombstoning. My issue is application hangs when i try for a sudden tombstone and come back. ie, After loading the page i press device menu button and with in seconds i pressed back button( Pressed Back button before the actual page disappeared) In that time the page loads but the application hangs / its back key press is not working. and if we try for a slow thombstone it is working perfectly. And the pretty interesting thing is that, while tombstoning the loaded and unloaded events of APP working perfectly. Please any one help me to solve this issue.
It sounds like your App has been deactivated, but not tombstoned. This results in neither the App or Page contrusctor being called, causing your app to act in unexpected ways. I highly recommend reading the Windows Phone Silverlight Application Life Cycle document. The relevant extract for said article:
This case can occur if the user
presses the Start and Back buttons on
the phone in quick succession. In this
case, the application received a
Deactivate event and the system was
starting to save the state of the
application to perform an application
tombstone. Before this operation is
completed, the app Activated event is
received. The system knows that the
application was not removed from
memory, so the flow of execution is
different. Specifically:
• The app constructor is not called.
• The page constructor is not called.
The only way for the application to determine
if this condition has occurred is to
set a flag to indicate if the page
constructor has been called. If you
notice in the above section, this flag
was set in the page constructor, and
cleared in the OnNavigateFrom event.
In this case, we will receive the
OnNavigatedTo event, but we will see
that the page constructor was not
called. This tells us that our
application was not tombstoned.
I have an application which adds an icon to the notification area (aka the "system tray") using Shell_NotifyIcon. The icon has a context menu with various important commands. When the app runs on the local system, the context menu works fine. However, when the app is run as a Terminal Services RemoteApp, right-clicking the icon does not display the context menu. The various keyboard-based methods for opening the context menu also don't work.
Double-clicking the icon still behaves as expected, so I know it's not totally broken. We need the context menu to work as well, though. Does anybody know what might be wrong?
Edit: One more piece of information: if I press Ctrl+Alt+End to open the Windows Security screen (which lets you log off, lock the session, etc), and then close that screen, the context menu starts working.
It appears that this happens because the application does not receive a WM_CONTEXTMENU notification in the RemoteApp case. The usual WM_RBUTTONDOWN and WM_RBUTTONUP notifications arrive, but that's all. Strangely, if you try to activate the context menu with the keyboard, you also receive WM_RBUTTONDOWN and WM_RBUTTONUP, even though the mouse wasn't involved. Pressing Ctrl+Alt+End appears to resolve this problem; the system starts sending normal WM_CONTEXTMENU notifications. My guess is that this is a bug in the remote desktop client process.
One potential fix would be to trigger the context menu using WM_RBUTTONUP, but that breaks keyboard accessibility, so I don't recommend it.
The workaround I settled on was the following:
When you see a WM_RBUTTONUP notification, set a timer with a short timeout (50-100ms).
When you see a WM_CONTEXTMENU notification, cancel the timer and display the context menu.
When the timer fires, cancel the timer and display the context menu.
This should work for local usage and RemoteApp usage. The timeout value in step 1 needs to be long enough that it doesn't expire before the WM_CONTEXTMENU comes in, but no longer.