0

It's an extension to this question. The combobox is resized but it is showing the last characters of the long string. How would I always force the combobox to show the string from the start? I checked all the provided methods by ComboBox in jface, but none could qualify to do the task. So I am assuming I would have to write a function for it. But how to go about writing it and attaching that value to combobox. Problem : How it is now How I would like it to be. Just upon selection enter image description hereenter image description here

Community
  • 1
  • 1
Saras Arya
  • 3,022
  • 8
  • 41
  • 71

1 Answers1

0

Usually you shoud be able to change the selected text of an editable Combo/CCombo with setSelection().

For example

combo.setSelection( new Point( 0, 0 ) )

would position the caret at the beginning of the text field of a combo box.

But apparently this doesn't work (any more?) on SWT on Windows (haven't tried other platforms).

After executing this snippet, the text begin end remains entirely selected. Also, this is seemingly unrelated to the length of the text. Here the entire text fits the width of the Combo. You can also replace Combo with CCombo, they both behave the same.

shell.setLayout( new FillLayout( SWT.HORIZONTAL ) );
Combo combo = new Combo( shell, SWT.NONE );
combo.add( "begin end" );
combo.select( 0 );
combo.setSelection( new Point( 0, 0 ) );

I'd suggest to file a bug against SWT and see what the SWT maintainers say.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • Filed a [bug](https://bugs.eclipse.org/bugs/show_bug.cgi?id=480123) as per your suggestion. What is generally the response time on that? – Saras Arya Oct 20 '15 at 05:19
  • I don't know. From my experience, there is no predictable 'response time'. If you need a solution in predictable time you should probably consult professional services. – Rüdiger Herrmann Oct 20 '15 at 07:13