Need to determine if AutoComplete popup is visible

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Need to determine if AutoComplete popup is visible

Postby oskar » Mon Sep 23, 2013 12:10 am

I've run into a problem that can only be solved if I had access to AutoCompletion's isPopupVisible method, which unfortunately is marked as private. I have a KeyListener that intercepts keyPressed in order to provide syntax indentation (among other things). It turns out that it overrides whatever key events are set up by AutoComplete, so if I press enter when the AutoComplete popup is visible, it is intercepted by my KeyListener and a newline is inserted.

I could solve this issue by simply not running my KeyListener when the AutoComplete popup is visible, but there is no way for me to determine this! I've attempted all sorts of ugly hacks to figure out when the popup is visible without any luck. I assume this will probably never be added, because I found a thread over a year ago in which the same thing was requested. If you have any advice, I would really appreciate it.
oskar
 

Re: Need to determine if AutoComplete popup is visible

Postby oskar » Mon Sep 23, 2013 1:08 am

I figured out a hacky solution for those who are interested. I found that java.awt.Window has a getOwnedWindows() method, which will include the AutoCompletePopupWindow after the first time it is summoned. So, I call the method and, if there is an owned window, I call its isVisible() method. That appears to work in my tests.
oskar
 

Re: Need to determine if AutoComplete popup is visible

Postby robert » Fri Sep 27, 2013 1:40 pm

Never say never. :D I've made that method public, so it'll be in the upcoming 2.5.1 release.
User avatar
robert
 
Posts: 794
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron