Bug 21619 - Programmatically dropdown a combo
Summary: Programmatically dropdown a combo
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P5 enhancement with 4 votes (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords: ui
: 75688 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-07-16 09:48 EDT by patricia CLA
Modified: 2008-05-19 15:49 EDT (History)
18 users (show)

See Also:


Attachments
Patch for Mac OS X version of setListVisible for read-only Combo (861 bytes, patch)
2007-12-06 01:43 EST, Scott Kovatch CLA
no flags Details | Diff
Simple test for Combo.setListVisible() (1.50 KB, text/plain)
2007-12-06 20:06 EST, Scott Kovatch CLA
no flags Details
Patch that tests 'visible' before setting list visible (937 bytes, patch)
2007-12-06 20:09 EST, Scott Kovatch CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description patricia CLA 2002-07-16 09:48:49 EDT
it doesn't exist a method to open the 
popup of the combo (like a setPopupVisible(true)in the JCombobox of swing)
Comment 1 patricia CLA 2002-07-25 04:12:44 EDT
It could be useful to implement dynamic positioning in the droppeddown combo 
while typing text (like the address combo of Internet Explorer for example).
Anyway there should be a mean to dropdown the combo when using only the 
keyboard.
Comment 2 Scott Sirovy CLA 2003-06-26 13:35:30 EDT
As a workaround, this utility class may help (win32 users):

import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.widgets.Combo;

public class Util {

    public void showPopup(Combo combo, boolean show) {
        if (!combo.isDisposed()) {
            OS.SendMessage(combo.handle, OS.CB_SHOWDROPDOWN, show ? 1 : 0, 0);
        }
    }

    public boolean isPopupShowing(Combo combo) {
        boolean result = false;
        if (!combo.isDisposed()) {
            result = (OS.SendMessage(combo.handle, OS.CB_GETDROPPEDSTATE, 0, 
0) != 0);
        }
        return result;
    }
}
Comment 3 Grant Gayed CLA 2004-10-06 09:45:10 EDT
*** Bug 75688 has been marked as a duplicate of this bug. ***
Comment 4 Steve Northover CLA 2004-10-06 13:00:02 EDT
This is low priority.  It isn't needed by Eclipse and the capability is not 
available on all platforms so we can't really offer the API.  I'm not sure how 
an application is supposed to use it (ie. what is "dynamic positioning while 
typing text").
Comment 5 Joe CLA 2004-10-13 10:13:24 EDT
I would really like to see this added.  I would like to add the ability to my 
commercial software for the user to type text into the combo box, by which 
triggers the combo box to open.

My idea, is that the combo box is searchable.  Meaning that if it contains 
identification numbers in accending order, that the user may type in a number 
which triggers the opening of the combo box.

I have the functionality written so that it will scroll the list, but am 
finding it difficult to trigger the dropdown to open when text is typed into 
the combo.
Comment 6 Steve Northover CLA 2005-05-24 10:11:05 EDT
Ok, I understand.
Comment 7 Damian Biollo CLA 2005-05-31 13:24:25 EDT
CCombo has an internal method called "dropDown" -- can this be made public?

It's pretty useful to be able to programmatically drop down a combo box.

I'm using a ComboBoxCellEditor in a GEF-based editor and want the combo to 
drop down right away when the cell editor is activated. This will eliminate an 
extra mouse click and make it easier to use.
Comment 8 Stefano Zaccaria CLA 2005-06-21 11:18:22 EDT
(In reply to comment #5)
> I would really like to see this added.  I would like to add the ability to 
my 
> commercial software for the user to type text into the combo box, by which 
> triggers the combo box to open.
> My idea, is that the combo box is searchable.  Meaning that if it contains 
> identification numbers in accending order, that the user may type in a 
number 
> which triggers the opening of the combo box.
> I have the functionality written so that it will scroll the list, but am 
> finding it difficult to trigger the dropdown to open when text is typed into 
> the combo.

Hello, so do I make a solution, but as you I have a problem with the dropdown. 
Moreover, my solution have problem with the last release of Eclipse 3.1RC3
Can you help me with this problem
Thanks
Stefano
Comment 9 Steve Northover CLA 2005-09-01 16:50:13 EDT
Since there is no API to do this on the Mac (implemented with HIComboBox or 
CreatePopupButtonControl()), we can't really offer the API, other than as a 
hint.
Comment 10 Benjamin Chen CLA 2005-09-27 16:57:39 EDT
(In reply to comment #2)
> As a workaround, this utility class may help (win32 users):

It seems my mouse cursor disappears if I do this work around.
Until the combo box list is closed.
Any work arounds for the workaround? 
Thanks
Comment 11 Tyler Holm CLA 2006-02-06 16:56:25 EST
(In reply to comment #5)
> I would really like to see this added.  I would like to add the ability to my 
> commercial software for the user to type text into the combo box, by which 
> triggers the combo box to open.
> My idea, is that the combo box is searchable.  Meaning that if it contains 
> identification numbers in accending order, that the user may type in a number 
> which triggers the opening of the combo box.
> I have the functionality written so that it will scroll the list, but am 
> finding it difficult to trigger the dropdown to open when text is typed into 
> the combo.


I have a separate button (w/ icon) that when pressed I'd like to show the Combo popup.  I would like it to do exactly as the JComboBox.showPopup() works
Comment 12 Steve Northover CLA 2006-02-07 22:13:23 EST
It seems that OS X 10.4 has added the API HIComboBoxSetListVisible() (ASIDE: also they added API to find out when an item is selected so we can get rid of the horrible hack in Display).

SSQ, we should consider adding this API providing that GTK and Motif can do it.  I'm thinking:

setListVisible(boolean);
getListVisible();

Comment 13 Randy Hudson CLA 2006-02-08 10:13:19 EST
regarding comment 1, on windows you can press F4 or ALT+DOWN_ARROW to show the combo box.

While you guys are investigating cross-platform combo functionality, could you also look into notification for the dropdown being shown and hidden. This affects many clients that currently suffer a large delay when handling a selection change event.
Comment 14 Dave Smith CLA 2007-02-09 10:46:53 EST
In the current 3.3 M4 build I see for Windows and GTK you have added asetListVisible method but it is not public. Any idea when it will be?
Comment 15 Steve Northover CLA 2007-02-09 12:22:44 EST
Still haven't investigated GTK, Motif and Photon.  Since M5 is supposed to be an API freeze, assuming the investigation was successful, we need approval from the PMC to add API.
Comment 16 Thomas Schindl CLA 2007-03-27 04:40:58 EDT
(In reply to comment #15)
> Still haven't investigated GTK, Motif and Photon.  Since M5 is supposed to be
> an API freeze, assuming the investigation was successful, we need approval from
> the PMC to add API.
> 

On GTK this is already implemented since some time at least M4 has a method named setListVisible() which is package scoped. Now that M6 is passed would you mind adding at least a package visible method to MacOSX?
Comment 17 Steve Northover CLA 2007-04-05 14:51:46 EDT
I added the method.  Note that I don't know how to drop down a read only combo (one created with CreatePopupButtonControl()) on the Mac.
Comment 18 blutkind CLA 2007-11-08 06:36:07 EST
Are there any updates on this issue? We really need to control read-only combo's drop-down list programmatically on mac. Plus, can't understand why the setListVisible method has package access?
Comment 19 Greg Howdeshell CLA 2007-12-05 09:05:42 EST
The use case I ran into for needing to know if the drop down is visible is I have added a org.eclipse.jface.fieldassist.ContentProposalAdapter to my read/write org.eclipse.swt.widgets.Combo and set the keystroke param and auto activation chars to null so whenever the user typed anything the proposals would display.  However, if the combo box has been expanded prior to typing, once the user begins to type the proposals display on top of the combo dropped down and the focus is kept on the drop down rather than the proposals.  It clutters the screen and user could become confused.  So my end result is that I wanted to know if the combo list is visible, disable the org.eclipse.jface.fieldassist.SimpleContentProposalProvider and interact with the combo list.  I had hoped the API would handle this case gracefully but if not, it would sure be nice to be able to handle this programmatically through a listener that is fired when the list is expanded.  So I知 asking for an additional enhancement to this bug to be able to catch when the list is displayed and closed.
Comment 20 Scott Kovatch CLA 2007-12-05 12:44:03 EST
Steve, can you use HIViewSimulateClick on the popup menu? That seems to be what you're trying to accomplish.
Comment 21 Scott Kovatch CLA 2007-12-05 14:38:05 EST
Guy F. says:

"HIViewSimulateClick with kControlPopupButtonPart is indeed the correct way to programmatically open the popup menu."

This might answer your question about how to programmatically drop down a top level menu item.
Comment 22 Scott Kovatch CLA 2007-12-06 01:43:50 EST
Created attachment 84594 [details]
Patch for Mac OS X version of setListVisible for read-only Combo

Here's a change to Combo that handles making a read-only popup visible. The change is as I described, but kControlPopupButtonPart is not exposed in any header. It's not exactly a magic value, however.
Comment 23 Steve Northover CLA 2007-12-06 18:11:50 EST
A google search for kControlPopupButtonPart gives nothing, making it magic ... but I don't care.  Does the code work with "0" instead of "1".  Did you test the patch?  It looks good providing that simulate click doesn't send any fake mouse events, which from reading the doc, is shouldn't.

We also need to implement Combo.getListVisible() but I have code around somewhere that checks to see whether a menu is open and that code should work fine.
Comment 24 Steve Northover CLA 2007-12-06 18:14:43 EST
I have released the HIComboBoxIsListVisible() native into HEAD.
Comment 25 Steve Northover CLA 2007-12-06 18:15:34 EST
... and /*public*/ boolean getListVisible() for Combo.
Comment 26 Scott Kovatch CLA 2007-12-06 20:06:49 EST
Created attachment 84693 [details]
Simple test for Combo.setListVisible()

Here's a test case. I'm going to modify the patch a bit because currently it shows the popup regardless of the state of the visible parameter. The other problem is that once visible, any click elsewhere in the window hides the list, and I don't think that behavior is controllable.
Comment 27 Scott Kovatch CLA 2007-12-06 20:09:45 EST
Created attachment 84694 [details]
Patch that tests 'visible' before setting list visible

Slightly better patch. Previous version didn't check for 'visible' first, so the list always gets shown.
Comment 28 Steve Northover CLA 2007-12-07 11:36:18 EST
There is also a few cross-platform issues that we need to think about.  For example, if the combo box is hidden, disabled or zero size, does the list still show?
Comment 29 Greg Howdeshell CLA 2007-12-07 12:09:55 EST
(In reply to comment #25)
> ... and /*public*/ boolean getListVisible() for Combo.

why was the changed checked in at package level rather than public?  If the change was public this would help my use case where I need to know if the list
is visible or not when the user begins to type in the combo box.  In addition, what was the thought on a way to catch via a listener when the list is opened and closed?
Comment 30 Scott Kovatch CLA 2007-12-07 13:03:21 EST
(In reply to comment #29)
> In addition, what was the thought on a way to catch via a listener when the list is opened
> and closed?

This is a good question; reading through the other comments, I can see where this might be useful. In Carbon we could get the menu handle and listen for kEventMenuOpening and kEventMenuClosed. Cocoa will fire a NSPopUpButtonWillPopUpNotification, but I don't see a matching close notification.
Comment 31 Steve Northover CLA 2007-12-07 13:31:57 EST
> why was the changed checked in at package level rather than public? 

While working on the API way back when, carbon didn't support the API.  We can't make a method public on one platform and not on another.  The /*public*/ is used to release the code and save the work in progress.  Normally, we don't do this for space reasons but the amount of code is small.
Comment 32 Steve Northover CLA 2007-12-07 20:06:11 EST
I have the code everywhere but cocoa.  Scott, got code?
Comment 33 Steve Northover CLA 2007-12-07 21:17:06 EST
Fixed > 20071207

Bogdan, my Linux machine is very old.  I'll need to test the code on your machine monday.

Duong, fix bug 119057 right away so that CCombo matches Combo for the next M-release.  There is a patch.  Be sure to update the Javadoc and the @since field.
Comment 34 Kim Horne CLA 2008-05-16 13:56:36 EDT
Steve, does this need a contributed tag?
Comment 35 Steve Northover CLA 2008-05-19 15:49:22 EDT
Nope.  Scott is a committer.