NS

Hi,

is there a way to catch when the cancel button is pressed?

What i really want is to remove the cancel button, and force users to enter text into my textbox.

by Francois Du Toit
Posted on Fri, 09/16/2011 - 14:47

Hi Nicolai,

Please give more information on what you are currently using. It will be more helpful if you include code snippets...

Normally you can find such information in the help files of the method you are using.

You can for instance use Constants.MSGBOX_BTN_OK as part of the code to specify that there should be an OK button only. But not knowing what you have been doing and what your code looks like makes it difficult to support.

 Here is a the example in the help files. You will see that there is a section where you can place data in the created fields, and a section where you retrieve the data.

var test = 0;
     function myDialog()
     {
      //all member functions except for getPages can access the property "dialog" of the dialog class. Type is "UserDialog" (see help).
      //example: this.dialog.getPage(0)

      // returns DialogTemplate[] (see help) or the dialog XML ID
      // non-optional
      this.getPages = function()
      {
      var iDialogTemplate1 = Dialogs.createNewDialogTemplate(600, 200, "First page");
      iDialogTemplate1.PushButton(35, 5, 80, 15, "Press", "BUTTON_1");
      iDialogTemplate1.CheckBox(120, 5, 100, 15, "CheckMe", "CHECKBOX_1");
      iDialogTemplate1.ComboBox(10, 60, 100, 40, ["Value 1", "Value 3", "Value 2", "Value 4"], "COMBO_1");
      iDialogTemplate1.DropListBox(355, 60, 100, 40, ["sorted 1", "sorted 3", "sorted 2", "sorted 4"], "COMBO_4", 3); //sorted + editable
      iDialogTemplate1.Text(10, 170, 100, 16, "stat. Text");
      iDialogTemplate1.TextBox(120, 170, 100, 16, "TXT_EDIT_1");
      var iDialogTemplate2 = Dialogs.createNewDialogTemplate(400, 200, "Second page");
      iDialogTemplate2.Text(10, 10, 100, 16, "stat. Text");
      iDialogTemplate2.TextBox(10, 40, 100, 16, "TXT_EDIT_2");
      iDialogTemplate2.TextBox(10, 80, 150, 16, "TXT_EDIT_3");
      return [iDialogTemplate1, iDialogTemplate2];
      }

     //initialize dialog pages (are already created and pre-initialized with static data from XML or template)
     //parameter: Array of DialogPage
     //see Help: DialogPage
     //user can set control values
     //optional
     this.init = function(aPages)
     {
        //use this function also to store the page data locally (for example to access it in "onClose")
        aPages[0].setFocusedElement("TXT_EDIT_1");
        aPages[0].getDialogElement("TXT_EDIT_1").setText("Start value 1");

        aPages[1].getDialogElement("TXT_EDIT_2").setText("Start value 2");
        aPages[1].getDialogElement("TXT_EDIT_3").setText("Start value text 3");
        aPages[1].setFocusedElement("TXT_EDIT_2");
    }

    // returns true if the page is in a valid state. In this case OK, Finish, or Next is enabled.
    // called each time a dialog value is changed by the user (button pressed, list selection, text field value, table entry, radio button,...)
    // pageNumber: the current page number, 0-based
    this.isInValidState = function(pageNumber)
    {
        return true;
    }

    // returns true if the "Finish" or "Ok" button should be visible on this page.
    // pageNumber: the current page number, 0-based
    // optional. if not present: always true
    this.canFinish = function(pageNumber)
    {
        return true;
    }

    // returns true if the user can switch to another page.
    // pageNumber: the current page number, 0-based
    // optional. if not present: always true
    this.canChangePage = function(pageNumber)
    {
        return true;
    }

    //called after ok/finish has been pressed and the current state data has been applied
    //can be used to update your data
    // pageNumber: the current page number
    // bOK: true=Ok/finish, false=cancel pressed
    //optional
    this.onClose = function(pageNumber, bOk)
    {
    }

    //the result of this function is returned as result of Dialogs.showDialog(). Can be any object.
    //optional
    this.getResult = function()
    {
        return this.dialog.getPage(1).getDialogElement("TXT_EDIT_2").getText()
    }

    //other methods (all optional): on[ControlID]_pressed, _focusChanged(boolean lost=false, gained=true), _changed for edit and toggle buttons, _selChanged(int[] newSelection)
    this.BUTTON_1_pressed = function()
    {
        this.dialog.getPage(0).getDialogElement("TXT_EDIT_1").setVisible(false)
        this.dialog.getPage(1).getDialogElement("TXT_EDIT_2").setEnabled(false)
        test = 1;
    }
}

var result = Dialogs.showDialog(new myDialog(), Constants.DIALOG_TYPE_WIZARD, "Multi page dialog");
Dialogs.MsgBox(result)

I hope this helps.

Kind regards,

Francois du Toit

0
by Deleted User
Posted on Fri, 09/16/2011 - 15:32

Hi Nicolai,

As Francois suggested, the easiest way of showing a message box without the Cancel button is to specify the Constants.MSGBOX_BTN_OK flag to the function Dialogs.MsgBox:

 

Dialogs.MsgBox("A message",  Constants.MSGBOX_BTN_OK, "A title")

Result:

 

Regarding the detection of the Cancel button press: the button pressed is always returned by the Dialogs.MsgBox function.

Example:

var btnPressed = Dialogs.MsgBox("...proceed?", Constants.MSGBOX_BTN_OKCANCEL, "Should I...")

switch (btnPressed) {
    case
        Constants.MSGBOX_RESULT_OK: Dialogs.MsgBox("Let's go!");
        break;
    case
        Constants.MSGBOX_RESULT_CANCEL: Dialogs.MsgBox("No go!");
        break;
    default:
        Dialogs.MsgBox("btnPressed is " + btnPressed);
}



Output...

If ok is pressed...

If cancel is pressed...

 

As you can see by the simple examples above, it's easy to:

  1. Control what buttons are show
  2. Find what button was pressed

Refer to ARIS Help for more options on the MsgBox function:

 

For a more customized dialog, check Francois' post. He has already pointed out some interesting directions.

Best luck!

0
by Nicolai S Author
Posted on Mon, 09/19/2011 - 11:07

Hi guys,

thanks for the input.

This is how I have made my dialog box:

function showDialog(sModelName) {
    var sText = formatString1(getString("TEXT_3"), sModelName);
                             
    return Dialogs.showDialog(new getDialog(), Constants.DIALOG_TYPE_ACTION, "");

    function getDialog() {
        this.getPages = function() {
            var dialogTemplate = Dialogs.createNewDialogTemplate(500, 200, "");
            dialogTemplate.Text(50, 0, 460, 50, sText);
            dialogTemplate.TextBox(50, 60, 460, 200, "TXT_EDIT", 1);
            dialogTemplate.OKButton();
            return [dialogTemplate];     
        }
        this.init = function(aPages) {
    
        }
        this.isInValidState = function(pageNumber) {
            return true;
        }
        this.canFinish = function(pageNumber) {
            return true;
        }
        this.canChangePage = function(pageNumber) {
            return true;
        }  
        this.onClose = function(pageNumber, bOk) {
          
        }
       
        this.getResult = function() {
            var sText = this.dialog.getDialogElement("TXT_EDIT").getText();
            return sText;
        }
    }
}

 

What I'm trying to achieve is to force the user to enter text into the textbox, and remove the cancel button.

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks
  • SS
  • MZ
  • Profile picture for user kbiront
  • Profile picture for user Tony Iliev
  • Profile picture for user amandeep.7.singh
  • PacMan

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock