I have an AIR application with muti level windows. Application A opens Window B which has subwindow C. Window B is listening for the system manager's Sandbox Event( Mouse Down Somewhere) to close itself.
systemManager.addEventListener(SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE)
But this event is dispatched when we click on the app (A) as well as the sub window(C). Is it possible to determine the origin of the sandbox event to prevent closing the window when click on its sub window. Thanks!
You can use event.target property in the listener function to determine which window the mouse down event occurs.
Related
Whats the difference between QDialog::show() and QDialog::open()?
show() will just show you the dialog without affecting the other windows in your program. open() will show() the window + prevent other windows from being accessible through setWindowModality(), i.e., it becomes a modal window.
This is useful if you want to open a file, for example, and you don't want the user to be able to do anything in the program until a file is chosen and that dialog is closed.
Quoting from Qt's manual:
A modal dialog is a dialog that blocks input to other visible windows in the same application. Dialogs that are used to request a file name from the user or that are used to set application preferences are usually modal. Dialogs can be application modal (the default) or window modal.
When an application modal dialog is opened, the user must finish interacting with the dialog and close it before they can access any other window in the application. Window modal dialogs only block access to the window associated with the dialog, allowing the user to continue to use other windows in an application.
The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will provide a useful return value. Typically, to get the dialog to close and return the appropriate value, we connect a default button, e.g. OK, to the accept() slot and a Cancel button to the reject() slot. Alternatively you can call the done() slot with Accepted or Rejected.
As it is stated in the doc, QDialog::open()
Shows the dialog as a window modal dialog, returning immediately.
whereas QDialog::show(), which is in fact QWidget::show(), will only show your dialog as a standard, non-modal widget.
I am using QWebView to display some flash content in this. I have been set the attribute of this window to be frameless and made it as a child window of some other process(Remote desktop Terminal session window).
I wanted to grab the ALT+F4 key press combination on this flash video. I mean to say if user clicks on the flash video(i.e. my QWebView window is in focus now), at that time if user presses ALT+F4, then I wanted to take some action on this event.
I have overridden keypressevent(QKeyEvent), but I am not getting this to be called , even though after setting the focus policy.
NOTE :- I am getting key press event only and only when user click on the QWebView window outside the flash area.
In my Flex (Flash Builder 4) Air application, I have a spark window , and have set the close="" event handler (also tried the 'closing' event) to a method that pops up an alert confirming if they want to close the window.
This worked fine in my normal browser based app as a TitleWindow, but now that it's an Air app with a native spark window, it's not working. I never see the alert dialog, and if I debug trace, it does in fact go in to my close handler method, but visually I can see the window is already gone from the screen.
In an AIR application, how do you add a confirmation dialog for when they click the "x" to close the window?
From the docs it looks like closing would be the one to do it, copied from the docs below:
closing Event
Event Object Type: flash.events.Event
property Event.type = flash.events.Event.CLOSING
Runtime Versions: AIR 1.0
Dispatched by this NativeWindow object immediately before the window is to be closed. This event can be canceled to prevent the window from being closed.
The Event.CLOSING constant defines the value of the type property of a closing event object.
This event has the following properties:
Property Value
bubbles false
cancelable true; canceling this event object stops the close operation.
currentTarget The object that is actively processing the Event object with an event listener.
target The object whose connection is to be closed.
Taken from:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#event:closing
It says close does happen after the window is closed but closing should be right before and can be cancelled to stop the window from closing.
I'd like to know what is the difference between MouseEvent.CLICK & MouseEvent.MOUSE_DOWN.
Because when i use MouseEvent.MOUSE_DOWN for a button to set full-screen view its doesn't work, instead of this MouseEvent.CLICK works. So what was the reason.
I don't specifically know about ActionScript, but in general a mouse click event consists of a mouse down event, followed by a mouse up.
MouseEvent.MOUSE_DOWN is dispatched when a user presses the mouse down but a MouseEvent.CLICK occurs when MouseEvent.MOUSE_DOWN is dispatched followed by a MouseEvent.MOUSE_UP event.
This is an important concept to consider when listening to events, in general I mostly use MouseEvent.CLICK on buttons as it is the logical interaction I would like to listen for. I want to make sure that button was both pressed and released.
And to answer why you cannot initilize full-screen mode:
"The ActionScript that initiates
full-screen mode can be called only in
response to a mouse click or keypress.
If it is called in other situations,
it will be ignored (in ActionScript
2.0) or throw an exception (in ActionScript 3.0)."
For more information you can read this:
Exploring full-screen mode in Flash Player 9
In ActionScript 3.0 the difference between MouseEvent.MOUSE_DOWN an MouseEvent.CLICK is as Matt Ball says, that the CLICK event is the act of down the mouse button into an object, and release it in the SAME object.
If you down the button in an object and then release it in other object you will have the next events triggered (in order):
Object 1
MouseEvent.MOUSE_DOWN
MouseEvent.ROLL_OUT // and MouseEvent.MOUSE_OUT
Object 2
MouseEvent.ROLL_IN // and MouseEvent.MOUSE_IN
MouseEvent.MOUSE_UP
But, if you press the button and release it in the same object you will have the next events triggered (in order):
Object 1 (the only one)
MouseEvent.MOUSE_DOWN
MouseEvent.MOUSE_UP
MouseEvent.CLICK
In my web application a lot of popups opened from the parent window using 'window.open'. So I want to close all those popups when my application's main window is closed. How can I do that?
It's a bit problematic to know that the user closes the window but assuming you do achieve that (by a close button or subscribing to the beforeUnload event) you can close the opened windows by following the next bullets:
When opening a window, save its
object which is returned from the
window.open method (preferably to an
array so you have all objects in a
central place).
When you find out the main window is
closing, execute the close method
on the saved window objects.
Another possibility:
Use timer on the opened windows to
check if opener is defined (you
can try to use typeof on a method in
the opener page).
When you find out the opener doesn't
exist, close the window.
There's no callback that will notify you that the user closed his browser.
its not possible! You cannot catch browser close event.
You can use model popups to be sure user closed popups before closing the main window.