NSButtonCell
The NSButtonCell class is a subclass of NSActionCell. An NSButtonCell object defines the user interface of a button, checkbox(switch), radio button, and any other clickable region of a view. For example, the NSButton subclass of NSControl uses a single NSButtonCell object to implement its user interface. The configuration of the NSButtonCell object controls how the NSButton object appears and behaves? but the NSButton object is what sends a message when clicked.
NSButtonCell類是NSActionCell類的子類镣陕。NSButtonCell對象定義了一個可與用戶交互的界面,這個可交互的區(qū)域可以是一個按鈕茁彭,復(fù)選框,單選框理肺,或者視圖上任何可點擊的區(qū)域。例如妹萨,NSButton類,它是NSControl的子類乎完,僅通過一個NSButtonCell對象就實現(xiàn)了與用戶的交互。NSButtonCell類的特性影響了NSButton類的外觀及動作狀態(tài)摩桶,NSButton類所做的就是在接受到點擊事件時,發(fā)送消息硝清。
Overview
Setting the integer, float, double, or object value of an NSButtonCell object results in a call to state with the value converted to integer. In the case of objectValue, nil is equivalent to 0, and a non-nil object that doesn't respond to intValue sets the state to 1. Otherwise? the state is set to the object's intValue. Similarly, for most button types, querying the integer, float, double, or object value of an NSButtonCell returns the current state in the requested representation. In the case of objectValue, this is an NSNumber containing YES for on, NO for off, and integer value -1 for the mixed state. For accelerator buttons (type NSAcceleratorButton or NSMultiLevelAcceleratorButton)? on systems that support pressure sensitivity,? querying doubleValue returns the amount of pressure applied while pressing the button.
給NSButtonCell對象設(shè)置一個整數(shù)值芦拿、小數(shù)士飒、浮點數(shù)或任何一種類型數(shù)值蔗崎,它都會先將這個值轉(zhuǎn)換為一個整數(shù),再用這個整數(shù)值來表示NSButtonCell對象的狀態(tài)缓苛。對于參數(shù)值,nil類型的值相當(dāng)于0他嫡,一個非nil的類型并不代表其值為1。另外徘熔,對象設(shè)置的整數(shù)值是多少,就會被設(shè)置成什么狀態(tài)淆党。相似地,對于大多數(shù)類型的button染乌,通過查詢一個NSButtonCell對象的整數(shù)值、小數(shù)台颠、浮點數(shù)或其它值,返回這個button當(dāng)前所要求設(shè)定的狀態(tài)串前。這個整數(shù)值实蔽,是一個NSNumber類荡碾,YES表示開啟狀態(tài),NO表示關(guān)閉狀態(tài)局装,-1表示混合狀態(tài)坛吁。對于系統(tǒng)里的一些加速器類的button(如NSAcceleratorButton 或 NSMultiLevelAcceleratorButton)劳殖,它們具有壓力靈敏度,當(dāng)在壓力作用于其上時拨脉,查詢它們的浮點值哆姻,會返回當(dāng)前作用的壓力值。
For more information on the behavior of NSButtonCell, see the NSButton and NSMatrix class specifications, and Button Programming Topics.
想要查詢更多關(guān)于NSButtonCell類的動作屬性信息女坑,可以查看NSButton類和NSMatrix類的特性填具,和Button Programming Topics统舀。
Exceptions
In its implementation of the compare: method (declared in NSCell), NSButtonCell raises an NSBadComparisonException if the otherCell argument is not of the NSButtonCell class.
異常信息
在其中的一個compare實現(xiàn)方法里匆骗,如果傳入的otherCell參數(shù)不是NSButtonCell類的話,NSButtonCell類會拋出一個NSBadComparisonException類的異常誉简。
func? - (NSComparisonResult)compare:(id)otherCell;