有時希望用ComboBox組件作為顯示大量相關資料,而不是真正作為選擇選項之用,但當打開ComboBox組件時,Mouse在選項上移動時,仍然出現Highlight,容易使人誤會。因此要作出一些修改,由於以下修改涉及ComboBox組件父類,所有FLA裡ComboBox組件都會受影響,為了方便開發時,可以混合正常版和修改版ComboBox組件在同一個FLA裡,所以特別加入一個屬性noSelection。只有當noSelection是true時,ComboBox組件以修改版運作,否則ComboBox組件仍然是正常版。打開Library:
Mouse在選項上移動時,便不會出現Highlight
修改Flash UI Components>Core Assets - Developer Only>FUIComponent Class Tree>FUIComponent SubClasses>FSelectableItem,到Layer "Methods",
到drawItem(),先插入如下Code:
FSelectableItemClass.prototype.drawItem = function(itmObj, selected) {
if (this.controller.noSelection) {
selected = false;
}
...
當選擇後,也不會出現被選選項,永遠只停在第1個選項(等於鍵盤無法控制)
修改Flash UI Components>Core Assets - Developer Only>FUIComponent Class Tree>FUIComponent SubClasses>FSelectableList,到Layer "Methods",
到selectionHandler(),先插入如下Code:
FSelectableListClass.prototype.selectionHandler = function(itemNum) {
if (this.noSelection) {
return;
}
...
使用方法
當有ComboBox組件需要是修改版,只要在它上加入Code:
onClipEvent (load) {
noSelection = true;
}
|