| 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]

> ### Controlling to indicate the user 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
>     #----------------------------------------------------------
>     use mpfc;

>     sub dialogep {
>       my ($object) = @_;
>       if ($object->getStatus() != $mpfc::WS_DIALOG_OK){    # A
>         $object->setVisible($mpfc::False);
>         return;
>       }
>       $str = $newvifi_003->getProperty("labelString");
>       if ( $str->getCharPtr() eq "" ){                     # 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 = $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;
>     }
>     1;

> 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. 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
>     #----------------------------------------------------------
>     use mpfc;

>     sub btnep {
>       my ($object) = @_;
>       $val = $newdial_001->popup();
>       if ($val == $mpfc::WS_DIALOG_OK){
>          $newvlab_007->setProperty("labelString","DIALOG OK!");
>       }elsif ($val == $mpfc::WS_DIALOG_NO){
>          $newvlab_007->setProperty("labelString","DIALOG NO!");
>       }elsif ($val == $mpfc::WS_DIALOG_CANCEL){
>          $newvlab_007->setProperty("labelString","DIALOG CANCEL!");
>       }
>       $tmp = $newvifi_003->getProperty("labelString");
>       $tmp2 = sprintf("INPUT: %s",$tmp->getCharPtr());
>       $newvlab_010->setProperty("labelString",$tmp2);

>       $val = $newradi_006->getProperty("value");
>       $tmp2 = sprintf("SELECT: %s",$val->getCharPtr());
>       $newvlab_011->setProperty("labelString",$tmp2);
>       return;
>     }
>     1;

Document Release 3.70 for WideStudio ver 3.70, May 2004

WideStudio documents index | Table of contents

Copyright(C) WideStudio Development Team, 1999-2004 | Last modified: May 25, 2004