Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » open combobox' dropdown programmatically?
open combobox' dropdown programmatically? [message #462702] Mon, 17 October 2005 09:57 Go to next message
arne anka is currently offline arne anka
Messages: 133
Registered: July 2009
Senior Member
i would like to drop down a combobox on "focus in", so the content is
presented to the user already, with no need to click the arrow-button.
another solution would be to transfer the "focus in" of the text-part to
the arrow-button immediately.

it's decisive the comboi drops down with just one key or mouse action
(while pressing TAB or clicking the mouse into the left part of the combo).

how to do that?
Re: open combobox' dropdown programmatically? [message #462706 is a reply to message #462702] Mon, 17 October 2005 11:02 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel Spiewak
Messages: 263
Registered: July 2009
Senior Member
Oooh, I'm not sure this is doable. I pretty good clue that something isn't supported is if you've never seen it in a native app. Um, I would go through the ComboBox javadoc with a fine tooth comb and see what you come up with. Also, you might try spoofing a mouse click event in the combo box onFocus (again, not sure how this could be done, but it's an idea). Also, if you're application is only going to be used on one platform and you know that this feature is natively supported, you could drop into C in a subclass of ComboBox. Just make sure you override checkSubclass() to return true.
Re: open combobox' dropdown programmatically? [message #462898 is a reply to message #462706] Thu, 20 October 2005 11:21 Go to previous messageGo to next message
Sebastien is currently offline Sebastien
Messages: 20
Registered: July 2009
Junior Member
Hello,
Remember all that talk about generating events ? Why not trigger a mouse
down event on the combo box? It should open it. No?

Seb
Re: open combobox' dropdown programmatically? [message #462899 is a reply to message #462898] Thu, 20 October 2005 11:44 Go to previous messageGo to next message
arne anka is currently offline arne anka
Messages: 133
Registered: July 2009
Senior Member
> Hello,
> Remember all that talk about generating events ? Why not trigger a mouse
> down event on the combo box? It should open it. No?

if you had read right, you would have read my "i try it, if i need it".
any questions then?
Re: open combobox' dropdown programmatically? [message #462903 is a reply to message #462702] Thu, 20 October 2005 13:57 Go to previous messageGo to next message
Boris Munivrana is currently offline Boris Munivrana
Messages: 23
Registered: July 2009
Junior Member
Hi Arne,

if Win32-only is an option for you, you might try out this little snippet.

Regards,

Boris

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;


public class CComboDemo {

/**
* Open a Combo programatically (Win32 only)
*
* @param combo
* Combo
* @param show
* (boolean) popped up or not?
*/
private static void showPopup(Combo combo, boolean show) {
if (!combo.isDisposed()) {
OS.SendMessage(combo.handle, OS.CB_SHOWDROPDOWN, show ? 1 : 0, 0);
}
}

/**
* Has the Combo already popped up? (Win32 only)
*
* @param combo
* Combo
* @return (boolean) popped up or not?
*/
private static boolean isPopupShowing(Combo combo) {
boolean result = false;
if (!combo.isDisposed()) {
result = (OS.SendMessage(combo.handle, OS.CB_GETDROPPEDSTATE, 0, 0) !=
0);
}
return result;
}

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Demonstrates drop down on focus in");

GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
shell.setLayout(gridLayout);

Text text = new Text(shell, SWT.BORDER);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(gridData);

final Combo combo = new Combo(shell, SWT.READ_ONLY);
for(int i = 0; i < 10; i++){
combo.add("ComboItem " + i);
};
combo.select(0);
combo.setLayoutData(gridData);
combo.addListener(SWT.FocusIn, new Listener(){
public void handleEvent(Event e){
showPopup(combo, !isPopupShowing(combo));
}
});

Button button = new Button(shell, SWT.PUSH);
button.setText("Push Me");
button.setLayoutData(gridData);

shell.setSize(330, 100);

Monitor primary = Display.getDefault().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = shell.getBounds();
Point pt = new Point(bounds.x + (bounds.width - rect.width) / 2,
bounds.y + (bounds.height - rect.height) / 2);
shell.setLocation(pt);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Re: open combobox' dropdown programmatically? [message #462906 is a reply to message #462899] Thu, 20 October 2005 16:08 Go to previous messageGo to next message
Sebastien is currently offline Sebastien
Messages: 20
Registered: July 2009
Junior Member
Hi,
I do think that I must of not read right cause I don't understand what you
mean. Did I miss a thread? I just wanted to give a hint on something that
might of worked.
Re: open combobox' dropdown programmatically? [message #462936 is a reply to message #462903] Fri, 21 October 2005 05:13 Go to previous messageGo to next message
arne anka is currently offline arne anka
Messages: 133
Registered: July 2009
Senior Member
> if Win32-only is an option for you, you might try out this little

thanks! win32 is one platform, but it should work on linux/gtk as well.
you do not know how to do that in gtk, do you?
Re: open combobox' dropdown programmatically? [message #462945 is a reply to message #462936] Fri, 21 October 2005 11:58 Go to previous messageGo to next message
Boris Munivrana is currently offline Boris Munivrana
Messages: 23
Registered: July 2009
Junior Member
Hi Arne,

I'm not familiar with the Linux/GTK API architecture; request for this
feature in a corresponding >>NATIVE<< forum and then look up
<<org.eclipse.swt.internal.gtk.OS>> and see if this can be realised with
the given infrastructure forwarded by IBM.

Regards,

Boris

arne anka wrote:

>> if Win32-only is an option for you, you might try out this little

> thanks! win32 is one platform, but it should work on linux/gtk as well.
> you do not know how to do that in gtk, do you?
Re: open combobox' dropdown programmatically? [message #463391 is a reply to message #462702] Fri, 04 November 2005 14:35 Go to previous messageGo to next message
Steve Northover is currently offline Steve Northover
Messages: 1636
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=21619

"arne anka" <arne.anka@ginguppin.de> wrote in message
news:op.sysmdxtauyrgnr@komhem...
> i would like to drop down a combobox on "focus in", so the content is
> presented to the user already, with no need to click the arrow-button.
> another solution would be to transfer the "focus in" of the text-part to
> the arrow-button immediately.
>
> it's decisive the comboi drops down with just one key or mouse action
> (while pressing TAB or clicking the mouse into the left part of the
combo).
>
> how to do that?
Re: open combobox' dropdown programmatically? [message #463417 is a reply to message #463391] Fri, 04 November 2005 16:05 Go to previous message
venkataramana m is currently offline venkataramana m
Messages: 86
Registered: July 2009
Member
So, Steve Northover (principal architect behind SWT) puts an end to all the debate over most-wanted dropdown simulation in the last post :-)
Previous Topic:How to add resize listener for CoolBarItem?
Next Topic:any method can SWT Label dislay special character
Goto Forum:
  


Current Time: Fri Jul 25 06:47:34 EDT 2014

Powered by FUDForum. Page generated in 0.12085 seconds