Scrollbars are protected so a simple subclass should be able to access them.
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Hayes Sent: Tuesday, January 08, 2008 4:29 AM To: [email protected] Subject: [flexcoders] How to find width of scrollbar in comboBox dropdown ? I'm having some brain ache with trying to find an easy solution to this one, and I'm wondering If I'm missing the obvious (again )? I'm trying to replace the hardcoded "var scrollBarWidth:int = 16;" line in the code below with one that actually reflects the true width of the scrollbar (say if it's been styled or skinned). I can see the scrollbar in the comboBoxes dropdown instance in the debugger ("scroll_verticalScrollbar"), however it is private. Is there an easier/better way to find it's width than extending the dropdown renderer to provide access to it? Perhaps via styles/skin properties? Or another approach entirely ? Apologies if this is a really stupid question, and thanks in advance for any pointers. Jim. package com.ifeedme.component { import flash.events.Event; import mx.controls.ComboBox; import mx.events.FlexEvent; /** * * @author jim Hayes * ExtendedComboBox : extends comboBox to provide a dropdownWidth that adjusts to the widest label * whenever the dataprovider is changed. */ public class ExtendedComboBox extends ComboBox { public function ExtendedComboBox() { super(); } public function adjustDropDownWidth(event:Event=null):void { if (this.dropdown == null) { callLater(adjustDropDownWidth) } else { var ddWidth:int = this.dropdown.measureWidthOfItems(-1,this.dataProvider.length); if (this.dropdown.maxVerticalScrollPosition > 0) { // we have vertical scrollbar var scrollBarWidth:int = 16; ddWidth += 16; } this.dropdownWidth = Math.max(ddWidth,this.width); } } override protected function collectionChangeHandler(event:Event):void { super.collectionChangeHandler(event); this.addEventListener(FlexEvent.VALUE_COMMIT,adjustDropDownWidth) } } } ______________________________________________________________________ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. ______________________________________________________________________

