I don't imagine that a moving a list component around is the correct choice here, but it could probably be done effectively with a simple popup menu.
Example:
First, add a dataset custom property to the text area and populate it in some way, so it has a column called username
.
Then, use the following script on the text area's mousePressed
event to generate the popup when the '@' key is pressed:
if event.shiftDown and event.keyCode == event.VK_2:
from java.awt.event import MouseEvent
userData = event.source.userData
userNames = list(userData.getColumnAsList(userData.getColumnIndex('username')))
innerTextArea = event.source.viewport.view
characterBounds = innerTextArea.modelToView2D(innerTextArea.caretPosition)
mouseEvent = MouseEvent(
innerTextArea,
MouseEvent.MOUSE_CLICKED,
system.date.toMillis(system.date.now()),
0,
int(characterBounds.x),
int(characterBounds.y),
1,
False)
def insertName(name):
return lambda typeName: innerTextArea.insert(name, innerTextArea.caretPosition)
menu = system.gui.createPopupMenu(userNames, [insertName(name) for name in userNames])
menu.show(mouseEvent, int(characterBounds.x), int(characterBounds.y))
Result: