WideStudio Logo
WideStudio
Programming Guide
WideStudio Index
Table of contents


The user dialog



How to make a simple user dialog

Try to make a simple user dialog with WSCdialog class. and the application has as following functions.


  • Pushing some button of the application,indicates this user dialog.

  • This dialog has an input field and a radio group.

  • The end of input of the dialog,check the input value whether it is right.

  • Indicates the result of input of the dialog on the label.


  • [A sample of the user dialog]

    This sample is provided by ws/sampes/Ruby/dialog/newproject.prj .

    Controlling to indicate the user dialog

    It is easy to see to control indicating the user dialog by a sample ws/samples/share/dialog/ . The dialog is often used as exclusive window to do the input and indicating some informations. So there is a bad case when it is implemented as usual window. For example,when it requires that the same dialog is called from more than on event procedure,if the dialog is usual window, it becomes complicated that receiving of the input value from it. But it is easy to receive it when it is as dialog,not as usual window, because the pop-up method of dialog returns the end of input in order to receive the input value form it.

    The following picture shows the difference of the indicating and receiving the input data between the usual window and the dialog.



    [The difference of the usual window and the dialog]

    See the following program, At first, make a user dialog instance by dropping from the [Window] section of the object box dialog and put the following instances on it.


  • WSCvifield* newvifi_003

  • WSCradioGroup* newradi_006


  • [A sample of the user dialog]

    The next,implement the procedure when the button [OK],[NO],[CANCEL] is pushed, and put it the dialog with WSEV_ACTIVATE trigger. In this procedure, check the input values whether they are right and indicates an error dialog if they are wrong.

    #----------------------------------------------------------
    #Function for the event procedure
    #----------------------------------------------------------
    import mpfc
    import newwin000
    
    def dialogep(object):
      if (object.getStatus() != mpfc.WS_DIALOG_OK):    # A
        object.setVisible(mpfc.False);
        return;
    
      str = newwin000.newvifi_003.getProperty("labelString"); 
      if ( str.getCharPtr() == "" ):              # B
        msg = mpfc.WSGIappMessageDialog();
        msg.setProperty("defaultPosition",mpfc.True);
        msg.setProperty("width",500);
        msg.setProperty("labelString",
               "Please input some string to the input field.");
        msg.popup();                         # C
        return;
      val = newwin000.newradi_006.getProperty("value");
      if ( val.getLong() == 0 ):                           # D
        msg = mpfc.WSGIappMessageDialog();
        msg.setProperty("defaultPosition",mpfc.True);
        msg.setProperty("width",500);
        msg.setProperty("labelString","Please select a item of the radio group.");
        msg.popup();                         # E
        return;
      object.setVisible(mpfc.False);         # F
      return
    mpfc.WSGFfunctionRegister("dialogep",dialogep)
    

    Call the getStatus method to receive an information which button [OK],[NO],[CANCEL] is pushed. At A,checks which the button is pushed. Puts the dialog out when the button is not [OK]. At B, checks the input of the instance: newvifi_003, and indicates an message dialog when its input is wrong at C and exits, At D, checks the input of the instance: newradi_006, and indicates an message dialog when its input is wrong at E and exits. At C, checks the input of the instance: newradi_006, and indicates an message dialog when its input is wrong at F and exits. Then puts the dialog out and the method popup() which is called to indicate this dialog and called this event procedure by pushing the buttons of dialog returns. It is important that to make the dialog disappeared, because if not,the method popup() will never return.

    The following program is an example to call the method popup() in order to indicate the dialog.



    [A sample window to indicate the user dialog]

    If the button [dialog!] is pushed, indicates the user dialog and receive the input values from the dialog, put them to the labels.

    The first label: The pushed button [OK],{NO],[CANCEL].

    The second label: The input of newvifi_003.

    The third label: The selection of newradi_006.

    #----------------------------------------------------------
    #Function for the event procedure
    #----------------------------------------------------------
    import mpfc
    import newwin000
    
    def btnep(object):
      val = newwin000.newdial_001.popup();
      if (val == mpfc.WS_DIALOG_OK):
         newwin000.newvlab_007.setProperty("labelString","DIALOG OK!");
      elif (val == mpfc.WS_DIALOG_NO):
         newwin000.newvlab_007.setProperty("labelString","DIALOG NO!");
      elif (val == mpfc.WS_DIALOG_CANCEL):
         newwin000.newvlab_007.setProperty("labelString","DIALOG CANCEL!");
    
      tmp = newwin000.newvifi_003.getProperty("labelString");
      tmp2 = "INPUT:" + tmp.getCharPtr();
      newwin000.newvlab_010.setProperty("labelString",tmp2);
    
      val = newwin000.newradi_006.getProperty("value");
      tmp2 = "SELECT: " + val.getCharPtr();
      newwin000.newvlab_011.setProperty("labelString",tmp2);
      return
    mpfc.WSGFfunctionRegister("btnep",btnep)
    


    Document Release 3.80 for WideStudio ver 3.80, Jan 2005


    WideStudio documents index | Table of contents

    Copyright(C) WideStudio Development Team, 1999-2005 Last modified: Jan 05, 2005