nsISupports
Last changed in Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2)Implemented by: @mozilla.org/focus-manager;1
as a service:
var focusManager = Components.classes["@mozilla.org/focus-manager;1"] .getService(Components.interfaces.nsIFocusManager);
void clearFocus(in nsIDOMWindow aWindow); |
void contentRemoved(in nsIDocument aDocument, in nsIContent aElement); Native code only! Obsolete since Gecko 2.0 |
void fireDelayedEvents(in nsIDocument aDocument); Native code only! |
void focusPlugin(in nsIContent aPlugin); Native code only! |
nsIDOMElement getFocusedElementForWindow(in nsIDOMWindow aWindow, in PRBool aDeep, out nsIDOMWindow aFocusedWindow); |
PRUint32 getLastFocusMethod(in nsIDOMWindow window); |
void moveCaretToFocus(in nsIDOMWindow aWindow); |
void elementIsFocusable(in nsIDOMElement aElement, in unsigned long aFlags); |
nsIDOMElement moveFocus(in nsIDOMWindow aWindow, in nsIDOMElement aStartElement, in unsigned long aType, in unsigned long aFlags); |
void setFocus(in nsIDOMElement aElement, in unsigned long aFlags); |
void windowHidden(in nsIDOMWindow aWindow); Native code only! |
void windowLowered(in nsIDOMWindow aWindow); Native code only! |
void windowRaised(in nsIDOMWindow aWindow); Native code only! |
void windowShown(in nsIDOMWindow aWindow, in PRBool aNeedsFocus); Native code only! |
Attribute | Type | Description |
activeWindow |
|
The most active (frontmost) window, or null if no window that is part of the application is active. Setting the activeWindow raises it, and focuses the current child window's current element, if any. Setting this to null or to a non-top-level window throws an NS_ERROR_INVALID_ARG exception. |
focusedElement |
|
The element that is currently focused. This will always be an element within the document loaded in focusedWindow or null if no element in that document is focused. Read only. |
focusedWindow |
|
The child window within the activeWindow that is focused. This will always be activeWindow , a child window of activeWindow or null if no child window is focused. Setting the focusedWindow changes the focused window and raises the toplevel window it is in. If the current focus within the new focusedWindow is a frame element, then the focusedWindow will actually be set to the child window and the current element within that set as the focused element. This process repeats downwards until a non-frame element is found. |
Constant | Value | Description |
FLAG_RAISE |
1 |
|
FLAG_NOSCROLL |
2 |
Do not scroll the element to focus into view. |
FLAG_NOSWITCHFRAME |
4 |
If attempting to change focus in a window that is not focused, do not switch focus to that window. Instead, just update the focus within that window and leave the application focus as is. This flag will have no effect if a child window is focused and an attempt is made to adjust the focus in an ancestor, as the frame must be switched in this case. |
FLAG_BYMOUSE |
0x1000 |
Focus is changing due to a mouse operation, for instance the mouse was clicked on an element. |
FLAG_BYKEY |
0x2000 |
Focus is changing due to a key operation, for instance pressing the tab key. This flag would normally be passed when MOVEFOCUS_FORWARD or MOVEFOCUS_BACKWARD is used. |
FLAG_BYMOVEFOCUS |
0x4000 |
Focus is changing due to a call to MoveFocus() . This flag will be implied when MoveFocus() is called except when one of the other mechanisms (mouse or key) is specified, or when the type is MOVEFOCUS_ROOT or MOVEFOCUS_CARET . |
FLAG_SHOWRING |
0x100000 |
Always show the focus ring or other indicator of focus, regardless of other state. |
MOVEFOCUS_FORWARD |
1 |
Move focus forward one element, used when pressing TAB. |
MOVEFOCUS_BACKWARD |
2 |
Move focus backward one element, used when pressing Shift+TAB. |
MOVEFOCUS_FORWARDDOC |
3 |
Move focus forward to the next frame document, used when pressing F6. |
MOVEFOCUS_BACKWARDDOC |
4 |
Move focus forward to the previous frame document, used when pressing Shift+F6. |
MOVEFOCUS_FIRST |
5 |
Move focus to the first focusable element. |
MOVEFOCUS_LAST |
6 |
Move focus to the last focusable element. |
MOVEFOCUS_ROOT |
7 |
Move focus to the root element in the document. |
MOVEFOCUS_CARET |
8 |
Move focus to a link at the position of the caret. This is a special value used to focus links as the caret moves over them in caret browsing mode. |
Clears the focused element within aWindow
. If the current focusedWindow
is a descendant of aWindow
, sets the current focusedWindow
to aWindow
.
void clearFocus( in nsIDOMWindow aWindow );
aWindow
NS_ERROR_INVALID_ARG
aWindow
is null
. Obsolete since Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Called when content has been removed.
void contentRemoved( in nsIDocument aDocument, in nsIContent aElement );
aDocument
aElement
Fire any events that have been delayed due to synchronized actions.
void fireDelayedEvents( in nsIDocument aDocument );
aDocument
Indicate that a plugin wishes to take the focus. This is similar to a normal focus except that the widget focus is not changed. Updating the widget focus state is the responsibility of the caller.
void focusPlugin( in nsIContent aPlugin );
aPlugin
nsIDOMElement getFocusedElementForWindow( in nsIDOMWindow aWindow, in PRBool aDeep, out nsIDOMWindow aFocusedWindow );
aWindow
focusedWindow
, then the returned element will be the application-wide focused element (the value of focusedElement
). The return value will be null
if no element is focused.aDeep
true
, then child frames are traversed and the return value may be the element within a child descendant window that is focused. If false
, then the return value will be the frame element if the focus is in a child frame.aFocusedWindow
aWindow
, or to aWindow
if aDeep
is false
. This will be set even if no element is focused.The currently focused element within aWindow
.
NS_ERROR_INVALID_ARG
null
.PRUint32 getLastFocusMethod( in nsIDOMWindow window );
window
null
, then the current focusedWindow
will be used by default. This has the result of retrieving the method that was used to focus the currently focused element.The method that was used to focus the element in window. This will either be 0, FLAG_BYMOUSE
or FLAG_BYKEY
.
Moves the selection caret within aWindow
to the current focus.
void moveCaretToFocus( in nsIDOMWindow aWindow );
aWindow
Check if given element is focusable.
boolean elementIsFocusable(in nsIDOMElement aElement, in unsigned long aFlags);
True if aElement is focusable.
Move the focus to another element. If aStartElement
is specified, then movement is done relative to aStartElement
. If aStartElement
is null
, then movement is done relative to the currently focused element. If no element is focused, focus the first focusable element within the document (or the last focusable element if aType
is MOVEFOCUS_END
). This method is equivalent to setting the focusedElement
to the new element.
Specifying aStartElement
and using MOVEFOCUS_LAST
is not currently implemented.
If no element is found, and aType
is either MOVEFOCUS_ROOT
or MOVEFOCUS_CARET
, then the focus is cleared. If aType
is any other value, the focus is not changed.
nsIDOMElement moveFocus( in nsIDOMWindow aWindow, in nsIDOMElement aStartElement, in unsigned long aType, in unsigned long aFlags );
aWindow
aStartElement
aType
aFlags
The element that was focused.
Changes the focused element reference within the window containing aElement
to aElement
.
void setFocus( in nsIDOMElement aElement, in unsigned long aFlags );
aElement
aFlags
Called when a document in a window has been hidden or otherwise can no longer accept focus.
void windowHidden( in nsIDOMWindow aWindow );
aWindow
Called when a window has been lowered.
void windowLowered( in nsIDOMWindow aWindow );
aWindow
Called when a window has been raised.
void windowRaised( in nsIDOMWindow aWindow );
aWindow
Called when a new document in a window is shown.
void windowShown( in nsIDOMWindow aWindow, in PRBool aNeedsFocus );
aWindow
aNeedsFocus
true
, then focus events are expected to be fired on the window if this window is in the focused window chain.