Kevin King
Kevin King

Reputation: 567

jface swt InputDialog with multiple lines

How can I change the Text control style with SWT.MULTI

I tried overriding the method but still the same

@Override
protected int getInputTextStyle() {
    return SWT.MULTI | SWT.BORDER;
}

enter image description here

Upvotes: 1

Views: 716

Answers (3)

greg-449
greg-449

Reputation: 111217

You need to change the layout on the dialog's text control to set a suggested height. To do this you will need to override createDialogArea and change the layout. Something like:

@Override
protected Control createDialogArea(Composite parent) {
  Control result = super.createDialogArea(parent);

  Text text = getText();  // The input text

  GridData data = new GridData(SWT.FILL, SWT.TOP, true, false);
  data.heightHint = convertHeightInCharsToPixels(5); // number of rows 
  text.setLayoutData(data);

  return result;
}

@Override
protected int getInputTextStyle() {
  return SWT.MULTI | SWT.BORDER;
}

Upvotes: 4

Coder ACJHP
Coder ACJHP

Reputation: 2224

For multiple line try this :

@Override
protected int getInputTextStyle() {
return SWT.MULTI | SWT.BORDER | SWT.WRAP |  SWT.V_SCROLL
 }

Upvotes: 0

Matthew Diana
Matthew Diana

Reputation: 1106

Try something like this:

@Override
protected int getInputTextStyle() {
    return SWT.MULTI | super.getInputTextStyle();
}

Upvotes: 0

Related Questions