| 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/samples/Ruby/dialog/ .

> ### 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.
> - Mpfc::WSCvifield newvifi_003
> - Mpfc::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
>     #----------------------------------------------------------
>     def dialogep(object)
>       if object.getStatus() != Mpfc::WS_DIALOG_OK    # A
>         object.setVisible(Mpfc::False)
>         return
>       end

>       str = $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
>       end
>       val = $newradi_006.getProperty("value")
>       if val == 0                            # D
>         msg = 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
>       end
>       object.setVisible(Mpfc::False)          # F
>     end

> 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. 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
>     #----------------------------------------------------------
>     def dialogep(object)
>       if object.getStatus() != Mpfc::WS_DIALOG_OK    # A
>         object.setVisible(Mpfc::False)
>         return
>       end

>       str = $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
>       end
>       val = $newradi_006.getProperty("value")
>       if val == 0                            # D
>         msg = 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
>       end
>       object.setVisible(Mpfc::False)          # F
>     end

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