Skip to content

Commit dc91692

Browse files
committed
Add ZoomChanged listener to MessageDialogue
When a zoom change occurs, the OS automatically scales the window based on the scale factor. However, since fonts do not always scale linearly, this can cause text in dialogues to be cut off. This change adds a ZoomChanged listener to MessageDialogue. When a zoomChanged event is triggered, the shell size is recomputed so that the contents are fit properly and text is not clipped.
1 parent 2a9d970 commit dc91692

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/MessageDialog.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
import org.eclipse.swt.SWT;
2121
import org.eclipse.swt.custom.CLabel;
2222
import org.eclipse.swt.graphics.Image;
23+
import org.eclipse.swt.graphics.Point;
2324
import org.eclipse.swt.layout.GridData;
2425
import org.eclipse.swt.layout.GridLayout;
2526
import org.eclipse.swt.widgets.Button;
2627
import org.eclipse.swt.widgets.Composite;
2728
import org.eclipse.swt.widgets.Control;
29+
import org.eclipse.swt.widgets.Event;
2830
import org.eclipse.swt.widgets.Label;
31+
import org.eclipse.swt.widgets.Listener;
2932
import org.eclipse.swt.widgets.Shell;
3033

3134
/**
@@ -283,6 +286,13 @@ protected void configureShell(Shell shell) {
283286
if (titleImage != null) {
284287
shell.setImage(titleImage);
285288
}
289+
shell.addListener(SWT.ZoomChanged, new Listener() {
290+
@Override
291+
public void handleEvent(Event e) {
292+
Point newSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
293+
shell.setBounds(shell.getBounds().x, shell.getBounds().y, newSize.x, newSize.y);
294+
}
295+
});
286296
}
287297

288298
@Override

0 commit comments

Comments
 (0)