简体   繁体   中英

Highlight text in the message of an SWT MessageBox

When I run this code:

MessageBox mb = new MessageBox(getShell());
mb.setText("Title");
mb.setMessage("Message");
mb.open();

I am presented with a message box. However, I am unable to use my mouse cursor to select the message so that I can copy it to my clipboard.

Is there any way to do this?

In short: No. The message box is provided by the respective platform (ie Windows, Linux or MacOS) and you cannot influence how the message is presented.

To be able to copy the message text you need to create a custom message dialog that uses a read-only Text widget to show the message and allows copying its content.

You may want to look into the JFace MessageDialog code for an example of a custom dialog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM