nsIControllers 编辑

content/xul/document/public/nsIControllers.idlScriptable 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

AttributeTypeDescription
commandDispatchernsIDOMXULCommandDispatcherObsolete 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:45 次

字数:9675

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文