nsIControllers 编辑
content/xul/document/public/nsIControllers.idl
Scriptable Represents a list of nsIController elements. Inherits from: nsISupports
Last changed in Gecko 1.9 (Firefox 3)This interface is used to manage instances of the nsIController
interface. Windows and text inputs have default controllers that allow commands such as cmd_copy
to act on the focused element or window. XUL elements can also have controllers, although they do not have any default controllers.
Implemented by: @mozilla.org/xul/xul-controllers;1
. You should not normally need to create an instance, as you normally need to alter the window or element's existing list of controllers. To create an instance, use:
var controllers = Components.classes["@mozilla.org/xul/xul-controllers;1"] .createInstance(Components.interfaces.nsIControllers);
Method overview
void appendController(in nsIController controller); |
nsIController getControllerAt(in unsigned long index); |
nsIController getControllerById(in unsigned long controllerID); |
unsigned long getControllerCount(); |
nsIController getControllerForCommand(in string command); |
unsigned long getControllerId(in nsIController controller); |
void insertControllerAt(in unsigned long index, in nsIController controller); |
void removeController(in nsIController controller); |
nsIController removeControllerAt(in unsigned long index); |
Attributes
Attribute | Type | Description |
commandDispatcher |
| Obsolete since Gecko 1.9 |
Methods
appendController()
Adds a controller to the end of the list.
void appendController( in nsIController controller );
Parameters
controller
- A controller to be added to the list of controllers.
Exceptions thrown
NS_ERROR_OUT_OF_MEMORY
getControllerAt()
Returns the controller instance at the given position.
nsIController getControllerAt( in unsigned long index );
Parameters
index
- The position of the wanted controller.
Return value
The controller at the given position.
Exceptions thrown
NS_ERROR_FAILURE
- The given index is out of range.
getControllerById()
Returns a controller given by its order, rather than position, of insertion.
nsIController getControllerById( in unsigned long controllerID );
Parameters
controllerID
- The ID (insertion order) of a controller.
Return value
The controller element that was inserted with that ID.
Exceptions thrown
NS_ERROR_FAILURE
- The ID is greater than the number of controllers that have been inserted, or the controller has since been removed.
getControllerCount()
Returns the current number of controllers.
unsigned long getControllerCount();
Parameters
None.
Return value
The number of controllers currently in the list of controllers.
getControllerForCommand()
Searches for a controller that supports the given command.
nsIController getControllerForCommand( in string command );
Parameters
command
- The name of a command, e.g.
cmd_copy
Return value
The first controller in the list that supports the given command.
getControllerId()
Returns the order of insertion of a controller.
unsigned long getControllerId( in nsIController controller );
Parameters
controller
- The controller for which you want to retrieve the insertion index.
Return value
The ID in which the controller was inserted.
Exceptions thrown
NS_ERROR_FAILURE
- The controller is not in the list of controllers.
insertControllerAt()
Inserts a controller at a specific position in the list of controllers. If the position is out of range, nothing happens.
void insertControllerAt( in unsigned long index, in nsIController controller );
Parameters
index
- The position within the list where you want the controller to be inserted.
controller
- The controller to be inserted into the list.
Exceptions thrown
NS_ERROR_OUT_OF_MEMORY
removeController()
Removes a controller from the list of controllers.
void removeController( in nsIController controller );
Parameters
controller
- The controller to be removed from the list.
Exceptions thrown
NS_ERROR_FAILURE
- The controller was not in the list of controllers.
removeControllerAt()
Removes a controller from the list of controllers.
nsIController removeControllerAt( in unsigned long index );
Parameters
index
- The index of the controller to be removed.
Return value
The controller that was removed.
Exceptions thrown
NS_ERROR_FAILURE
- The index was out of range.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论