Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » MessageBox
MessageBox [message #465323] Fri, 09 December 2005 05:31 Go to next message
Eclipse UserFriend
Originally posted by: osipov.appliedtech.ru

Hi, everybody!
How do I initially set default button in org.eclipse.swt.widgets.MessageBox
to something else apart from SWT.YES?
thanks a lot in advance.
Re: MessageBox [message #465352 is a reply to message #465323] Fri, 09 December 2005 16:05 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Create with the right style bits

e.g.
SWT.OK | SWT.CANCEL
SWT.YES | SWT.NO
SWT.RETRY | SWT.ABORT | SWT.IGNORE



"Peter Osipov" <osipov@appliedtech.ru> wrote in message
news:dnb4rt$3ua$1@news.eclipse.org...
> Hi, everybody!
> How do I initially set default button in
> org.eclipse.swt.widgets.MessageBox
> to something else apart from SWT.YES?
> thanks a lot in advance.
>
>
Re: MessageBox [message #465379 is a reply to message #465352] Mon, 12 December 2005 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: osipov.appliedtech.ru

Veronika, thanks a lot for your reply.
That is what I do
MessageBox box = new MessageBox(getView().getViewSite().getShell(),
SWT.YES | SWT.NO | SWT.ICON_QUESTION);
when I open this box SWT.YES is a default button, that is if I press enter
YES-button will be selected, but I need NO to be selected by default.
I mean, I did the way you advised me to, but it did not help.

> Create with the right style bits
>
> e.g.
> SWT.OK | SWT.CANCEL
> SWT.YES | SWT.NO
> SWT.RETRY | SWT.ABORT | SWT.IGNORE
>
>
>
> "Peter Osipov" <osipov@appliedtech.ru> wrote in message
> news:dnb4rt$3ua$1@news.eclipse.org...
> > Hi, everybody!
> > How do I initially set default button in
> > org.eclipse.swt.widgets.MessageBox
> > to something else apart from SWT.YES?
> > thanks a lot in advance.
> >
> >
>
>
Re: MessageBox [message #465391 is a reply to message #465379] Mon, 12 December 2005 15:12 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
I guess I misunderstood your question.

No, there is no way to change the default button in MessageBox.

"Peter Osipov" <osipov@appliedtech.ru> wrote in message
news:dnj086$7l7$1@news.eclipse.org...
> Veronika, thanks a lot for your reply.
> That is what I do
> MessageBox box = new MessageBox(getView().getViewSite().getShell(),
> SWT.YES | SWT.NO | SWT.ICON_QUESTION);
> when I open this box SWT.YES is a default button, that is if I press enter
> YES-button will be selected, but I need NO to be selected by default.
> I mean, I did the way you advised me to, but it did not help.
>
>> Create with the right style bits
>>
>> e.g.
>> SWT.OK | SWT.CANCEL
>> SWT.YES | SWT.NO
>> SWT.RETRY | SWT.ABORT | SWT.IGNORE
>>
>>
>>
>> "Peter Osipov" <osipov@appliedtech.ru> wrote in message
>> news:dnb4rt$3ua$1@news.eclipse.org...
>> > Hi, everybody!
>> > How do I initially set default button in
>> > org.eclipse.swt.widgets.MessageBox
>> > to something else apart from SWT.YES?
>> > thanks a lot in advance.
>> >
>> >
>>
>>
>
>
>
Re: MessageBox [message #465400 is a reply to message #465323] Mon, 12 December 2005 18:40 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
It's fairly easy to roll your own MessageBox styled implementation which looks exactly like MessageBox but can be configured to have whichever button(s) you want (and whichever you want defaulted). However, it won't be quite native on every platform unless you *really* do your homework and have a lot of conditional widget creation and layout logic. Still, it's possible and it might be your only solution. To get the platform specific question image, use Display#getSystemImage(SWT.ICON_QUESTION) There are quite a few other styles you can use - you get the idea. Hope this was helpful.
Re: MessageBox [message #465405 is a reply to message #465391] Mon, 12 December 2005 19:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mwilli.iastate.edu

Perhaps this is something you can request for a future version.
Something like:

MessageBox box = new MessageBox(getView().getViewSite().getShell(),
SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setDefaultButton(SWT.NO);

It wouldn't be a difficult implementation since a Shell already has the
capability.

Mike

Veronika Irvine wrote:
> I guess I misunderstood your question.
>
> No, there is no way to change the default button in MessageBox.
>
> "Peter Osipov" <osipov@appliedtech.ru> wrote in message
> news:dnj086$7l7$1@news.eclipse.org...
>> Veronika, thanks a lot for your reply.
>> That is what I do
>> MessageBox box = new MessageBox(getView().getViewSite().getShell(),
>> SWT.YES | SWT.NO | SWT.ICON_QUESTION);
>> when I open this box SWT.YES is a default button, that is if I press enter
>> YES-button will be selected, but I need NO to be selected by default.
>> I mean, I did the way you advised me to, but it did not help.
>>
>>> Create with the right style bits
>>>
>>> e.g.
>>> SWT.OK | SWT.CANCEL
>>> SWT.YES | SWT.NO
>>> SWT.RETRY | SWT.ABORT | SWT.IGNORE
>>>
>>>
>>>
>>> "Peter Osipov" <osipov@appliedtech.ru> wrote in message
>>> news:dnb4rt$3ua$1@news.eclipse.org...
>>>> Hi, everybody!
>>>> How do I initially set default button in
>>>> org.eclipse.swt.widgets.MessageBox
>>>> to something else apart from SWT.YES?
>>>> thanks a lot in advance.
>>>>
>>>>
>>>
>>
>>
>
>
Re: MessageBox [message #465427 is a reply to message #465400] Tue, 13 December 2005 05:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: osipov.appliedtech.ru

Anyway, thanks a lot guys!
What if I inherit my own message box from the existing one and add just one
method. Will that do?
Re: MessageBox [message #465429 is a reply to message #465405] Tue, 13 December 2005 05:55 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
Not all platforms have native support for that kind of feature. MessageBox takes the Least-Common-Denominator approach in its features. Yes, some platforms support more (in some cases quite a bit more) than what MessageBox offers, but anything more wouldn't be portable.

MessageBox is implemented as a pure peering to the corresponding native dialogs. Shell#setDefaultButton(Button) doesn't apply since SWT doesn't actually have a reference to the native shell (on most platforms). And even if it did, SWT doesn't have a reference to the native button handle, so it can't make it default. Yes, there could be more features added later which would be done through emulation. Dialogs are simple enough and uniform enough that emulation probably wouldn't even be noticed (except by the very picky). If you think SWT should do something like that, file a feature request. But as I've mentioned before, you shouldn't have any trouble emulating the same features.
Re: MessageBox [message #465444 is a reply to message #465427] Tue, 13 December 2005 13:50 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You will not be able to get a handle to the buttons in any platform
independant way. MessageBox is not intended to be subclassed.

"Peter Osipov" <osipov@appliedtech.ru> wrote in message
news:dnlnds$q4q$1@news.eclipse.org...
> Anyway, thanks a lot guys!
> What if I inherit my own message box from the existing one and add just
> one
> method. Will that do?
>
>
>
Re: MessageBox [message #465453 is a reply to message #465444] Wed, 14 December 2005 04:41 Go to previous message
Eclipse UserFriend
Originally posted by: osipov.appliedtech.ru

Oh, right. What a pity. Anyway, Veronika, thanks a lot for your support.


> You will not be able to get a handle to the buttons in any platform
> independant way. MessageBox is not intended to be subclassed.
>
> "Peter Osipov" <osipov@appliedtech.ru> wrote in message
> news:dnlnds$q4q$1@news.eclipse.org...
> > Anyway, thanks a lot guys!
> > What if I inherit my own message box from the existing one and add just
> > one
> > method. Will that do?
> >
> >
> >
>
>
Previous Topic:Switched to CCombo from Text default button does not work when focus in CCombo
Next Topic:Using ScrolledComposite on the J9 JVM
Goto Forum:
  


Current Time: Tue Apr 23 10:48:43 GMT 2024

Powered by FUDForum. Page generated in 0.04061 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top