Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » Custom alert window when clicking on menus
Custom alert window when clicking on menus [message #1831141] Wed, 12 August 2020 06:06 Go to next message
Eclipse UserFriend
Hi, how can I make a custom alert window that triggers when you click a menu?

For example, if clicking the menu triggers some potentially unwanted and permanent changes to a database, I want to warn the user about this danger. So a popup window shows up with a custom message and halts the action till the user acknowledges the risks and confirms by clicking a "confirm" button on that popup.

thanks for your help, much appreciated
Re: Custom alert window when clicking on menus [message #1831142 is a reply to message #1831141] Wed, 12 August 2020 06:31 Go to previous messageGo to next message
Eclipse UserFriend
MessageBox and MessageBoxes.

For example look at the utility methods such as
MessageBoxes.showDeleteConfirmationMessage()

or create your own full featured message as for example
        int result=MessageBoxes.create()
                .withHeader("My Header")
                .withBody("My text")
                .withYesButtonText("Yes go ahead")
                .withNoButtonText("No, stop")
                .withCancelButtonText("Cancel, i mistyped")
                .withSeverity(IStatus.WARNING)
                .show();
        if(result== IMessageBox.YES_OPTION){
            //...
        }
Re: Custom alert window when clicking on menus [message #1831143 is a reply to message #1831141] Wed, 12 August 2020 06:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi there

The MessageBox is what you are looking for.
MessageBox Demo
SourceCode of Demo (Widgets App)

You can create one using the MessageBoxes factory. Example:

int result = MessageBoxes
  .createYesNo()
  .withHeader("Delete entry?")
  .withBody("We will delete two entries")
  .withSeverity(IStatus.WARNING)
  .show();

The result returned will be one of the constants (IMessageBox: YES_OPTION, NO_OPTION, CANCEL_OPTION).

Note: For a simple deletion confirmation with YES and NO, the MessageBoxes factory offers convenience methods to build the message.

[Updated on: Wed, 12 August 2020 06:36] by Moderator

Re: Custom alert window when clicking on menus [message #1831144 is a reply to message #1831141] Wed, 12 August 2020 06:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

have a look at the class org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes. It has predefined popup message methods like showDeleteConfirmationMessage() or createYesNoCancel(). In your menus execAction() method you can use code like
if (MessageBoxes.showDeleteConfirmationMessage(myItems.toArray(new String[0]))) {
          for (IMyItem item : myItems) {
            myDelete(item);
          } 
     // potentially update what is shown
Re: Custom alert window when clicking on menus [message #1831156 is a reply to message #1831141] Wed, 12 August 2020 10:13 Go to previous message
Eclipse UserFriend
Thanks to everyone for your replies and hints. Also, thanks for linking that widget demo app, it is a useful resource for learning these basic things.
Previous Topic:TablePage Row-Specific Refreshs
Next Topic:Logging Help
Goto Forum:
  


Current Time: Wed Jul 02 16:32:40 EDT 2025

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

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

Back to the top