Combo working like Select
I'm continuing to fine-tune the use of the combo control in my ActiveWidgets application, using the following function:
<code>
function set_combo_behavior(combo)
{
var edit_box = combo.getContent("box/text");
edit_box.setAttribute("readonly",true);
combo.onControlEditStarted = function() {
var element = this.getContent("box/text").element();
element.contentEditable = false;
element._onkeydown = document.onkeydown;
document.onkeydown = combo_field_onkeydown;
element.onblur = combo_field_onblur;
}
combo.AW_showPopup = combo.showPopup;
combo.showPopup = function() {
this.AW_showPopup();
var selected_item = this.getSelectedItems();
var AW_onCurrentItemChanged = this.onCurrentItemChanged;
this.onCurrentItemChanged = null;
this.setCurrentItem(selected_item);
this.onCurrentItemChanged = AW_onCurrentItemChanged;
}
edit_box.setEvent("onclick", function() { this.showPopup(); });
combo.type_select = '';
combo.last_key_time = 0;
combo.delay_enabled = false;
combo.waiting_type_ahead = false;
}
</code>
The only problems I'm still having involve highlighting in the edit field and highlighting the selected item in the list when the dropdown list is displayed. The "setCurrentItem" call above at least scrolls the dropdown list to the correct part of the list when it pops up, but I have been unable to find any way to highlight the selected item. Also, when the user tabs into the combo field, if the currently selected item is blank, the edit field is not highlighted, which is confusing to the users. Is there a way to highlight the entire combo edit field, regardless of the length of the text in the combo edit field?
<code>
function set_combo_behavior(combo)
{
var edit_box = combo.getContent("box/text");
edit_box.setAttribute("readonly",true);
combo.onControlEditStarted = function() {
var element = this.getContent("box/text").element();
element.contentEditable = false;
element._onkeydown = document.onkeydown;
document.onkeydown = combo_field_onkeydown;
element.onblur = combo_field_onblur;
}
combo.AW_showPopup = combo.showPopup;
combo.showPopup = function() {
this.AW_showPopup();
var selected_item = this.getSelectedItems();
var AW_onCurrentItemChanged = this.onCurrentItemChanged;
this.onCurrentItemChanged = null;
this.setCurrentItem(selected_item);
this.onCurrentItemChanged = AW_onCurrentItemChanged;
}
edit_box.setEvent("onclick", function() { this.showPopup(); });
combo.type_select = '';
combo.last_key_time = 0;
combo.delay_enabled = false;
combo.waiting_type_ahead = false;
}
</code>
The only problems I'm still having involve highlighting in the edit field and highlighting the selected item in the list when the dropdown list is displayed. The "setCurrentItem" call above at least scrolls the dropdown list to the correct part of the list when it pops up, but I have been unable to find any way to highlight the selected item. Also, when the user tabs into the combo field, if the currently selected item is blank, the edit field is not highlighted, which is confusing to the users. Is there a way to highlight the entire combo edit field, regardless of the length of the text in the combo edit field?
Randall Severy
March 22,