# Dropdown List Events

**URL:** <https://forum.inductiveautomation.com/t/dropdown-list-events/90537>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [May 17, 2024, 1:15am UTC](https://forum.inductiveautomation.com/t/dropdown-list-events/90537 "2024-05-17T01:15:51Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 17, 2024, 2:34am UTC](https://forum.inductiveautomation.com/t/dropdown-list-events/90537/4 "2024-05-17T02:34:11Z")

</div>

> [@Devin\_Golberg](#):
>
> put the same code into keyReleased (for enter/space keyboard selection) and propertyChange (for mouse selection)

I recommend either setting up a custom method or a library script to avoid redundancy.

**Example:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e635292990aa242bd0de912cac58c6ee369984b1.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/9/49e073e8cf5a9bd6771dfa1752e7bb15084bda43.png)

Then on your `propertyChange` event handler, call the method anytime a selection change closes the dropdown _[mouse selection]_

```python
# handle slection changes that are triggered by the mouse
if event.propertyName == 'selectedStringValue' and not event.source.popupVisible:
	event.source.filterNextDropdown()

```

For the key released event handler the code would look something like this:

```python
if event.keyCode == event.VK_ENTER or event.keyCode == event.VK_SPACE:
	event.source.filterNextDropdown()

```

...and it's probable that you should also consider focusLost for when people click away.

_ **...or** _ another option would be to simply add a custom listener to detect when the dropdown menu closes, and perform the filtering actions directly from there.  
**Example:**

```python
# Written for the propertyChange event handler of a dropdown component

# Only runs one time at initialization
# Won't run in the designer unless preview mode is active prior to the window being opened
if event.propertyName == 'componentRunning':
	from javax.swing.event import PopupMenuListener
	class PopupCloseListener(PopupMenuListener):
		def popupMenuCanceled(self, event):
			pass # No action needed for this event
		
		def popupMenuWillBecomeVisible(self, event):
			pass # No action needed for this event
		
		def popupMenuWillBecomeInvisible(self, event):
			print event.source.selectedStringValue
			# perform the filtering actions here
	
	event.source.addPopupMenuListener(PopupCloseListener())

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/dropdown-list-events/90537)._
