AE ENHANCERS

Expressions/Scripts/Presets
It is currently Sat May 18, 2013 4:38 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Updating dropdown list on click
PostPosted: Fri Jan 14, 2011 7:07 am 
Hi Guys,

I've been banging my head against a brick wall with this for two days now. I have a ScriptUI with a dropdown list of 3D layers. The list needs to update when the user clicks the dropdown. So I capture the focus event with an onActivate, and rebuild the list as the user clicks. The problem is that rebuilding the list prevents the list from displaying, requiring a second click to show it. I'm guessing that rebuilding the list triggers an onChange event that automatically hides the list.

OK...it's not disastrous, but it's annoying.

I thought of forcing the dropdown list to show at the end of the onActivate handler, but can't find any command that does this. I've tried capturing the events further up the UI hierarchy, but without much luck. I've tried the show() method, faking UI or custom events with dispatch() and notify(), but nothing works. I'm clutching at straws now.

I'm wondering if there is even a scripting way to pop up a dropdown menu.

The best workaround I've got so far is updating the list on a mouseover which doesn't interfere with the click, but if one of the 3D layers in the list has been removed in the meantime, there's a nasty jump on rollover.

Can anyone help before I go insane? :)

Thanks.

Ben.


Top
  
 
 Post subject: Re: Updating dropdown list on click
PostPosted: Fri Jan 14, 2011 9:10 am 
I've been working a bit further and I'm going to condense my question:

Is there a way to change the contents of a dropdown menu when a user clicks it without the menu disappearing (or failing to show)?

And is there a way to drop down a dropdown menu from script without the user clicking it?

Hope that's a bit more succinct.

Thanks if you can help.

Ben.


Top
  
 
 Post subject: Re: Updating dropdown list on click
PostPosted: Sat Jan 15, 2011 5:21 am 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 645
Location: London, UK
Why does your listbox disappear when clicked? Is that something you've coded it to do?

If you have an "onChange" function that you don't want to be called, you can temporarily set it to null (e.g. listbox.onChange = null) while updating the listbox, then reassign it to the onChange function when you're done.

Do you have some test code you could post so we don't have to write a test script from scratch?

Paul


Top
 Profile  
 
 Post subject: Re: Updating dropdown list on click
PostPosted: Mon Jan 17, 2011 1:29 pm 
Hi Paul,

It seems that changing the contents of a drop down list at the point the user clicks it automatically makes the dropdown disappear.

I made the script linked below to test the UI, with a big edit text window to show the events as they're caught by handlers at various levels in the UI hierarchy. Incidentally... the event order I get doesn't seem to quite correspond to the capture / target / bubble described in the documentation.

If you run the script in AE with a couple of 3D layers selected, you see the problem. On the first click of the dropdown, nothing happens... on the second it works. Then it continues to work until the focus is taken away from the dropdown (by clicking the clear button for instance) and then the process repeats. Here the list is being initialised when focus lands on the dropdown.

If I remove the call to the ddInit(); function at line 135, the functionality of the dropdown returns. If I put the ddInit() on the mouseDown instead of focus by uncommenting line 104 and commenting out line 97, then the dropdown never drops down at all. The only reason it works after the first click with the focus method is that the focus is already on the dropdown.

http://www.benrollason.com/temp/aenhancers/UItest4.jsx (The test script is 300 lines or so, so I thought I'd post a file rather than clog up the browser window)

If you've got time and energy, let me know if you can make head or tail of it.

Thanks.

Ben.


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group