views:

191

answers:

1

I am displaying a combo box in something of a WYSIWYG preview. I want the user to be able to click on the combo box and see the options inside, but I don't want them to be able to change the value. I tried using preventDefault() on the change event but it doesn't work. I don't want to disable it because I do want the user to be able to "look inside" the dropdown.

So I'm trying to block the change, but can't. My next resort is to change the selected index back to what it was before the change, Is there any way to do this within the scope of a ListEvent.CHANGE event listener?

Current Workaround is to basically re-assign the controls selected item the same way I am defining the selected item when I originally build it (a default selection). So a user sees their change then it immediately changes back to the default selection.

+1  A: 

Are you sure that a combobox is what you want? could you do the same thing with a list component that is not selectable?

update:

If you must use a combobox and you dont want the lag from listening for the event and resetting the control, I see two possible options. You could subclass the control and make your own. When you do, hijack any methods that set the value besides the initial selection.

Or, you could try something like this: http://wmcai.blog.163.com/blog/static/4802420088945053961/. The site seems like it is in another language but the code is still there. It will allow you to make your options disabled, so the user cannot choose one of the other options.

HTH

Ryan Guill
Project sponsors want the WYSIWYG preview to match the thing it's previewing, which has combo boxes. My hands are tied on this one :-/
invertedSpear
check my updated answer and see if that helps you any.
Ryan Guill
You're right, I should just hijack the methods. I'll check out that site, but I think it's in a maintenance window right now (hard to say cause I don't even know what language that is).
invertedSpear