| 2424 | o._labels.append(Label({"__text": contents})) |
| 2425 | |
| 2426 | def fixup(self): |
| 2427 | ListControl.fixup(self) |
| 2428 | # Firefox doesn't exclude disabled items from those considered here |
| 2429 | # (i.e. from 'found', for both branches of the if below). Note that |
| 2430 | # IE6 doesn't support the disabled attribute on OPTIONs at all. |
| 2431 | found = [o for o in self.items if o.selected] |
| 2432 | if not found: |
| 2433 | if not self.multiple or self._select_default: |
| 2434 | for o in self.items: |
| 2435 | if not o.disabled: |
| 2436 | was_disabled = self.disabled |
| 2437 | self.disabled = False |
| 2438 | try: |
| 2439 | o.selected = True |
| 2440 | finally: |
| 2441 | o.disabled = was_disabled |
| 2442 | break |
| 2443 | elif not self.multiple: |
| 2444 | # Ensure only one item selected. Choose the last one, |
| 2445 | # following IE and Firefox. |
| 2446 | for o in found[:-1]: |
| 2447 | o.selected = False |
| 2448 | |
| 2449 | |
| 2450 | #--------------------------------------------------- |