Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

GUI Event Modes

How do you make something happen when a button is clicked on your GUI? There are two different event modes you can use to cause a reaction in your script when a button is pressed:

  1. MessageLoop (default). This is the default mode; it causes the GUI only to respond to events if the GuiGetMsg() function is called. It is wise to call this function many times per second in a loop; otherwise, you will have a slow or unresponsive GUI. The following loop continuously calls the GuiGetMsg() function until one of the two buttons are pressed or the user attempts to close the GUI:

    While 1
            $guimsg = GuiGetMsg()
            Select
                Case $guimsg = $GUI_EVENT_CLOSE
                    Exit ; closes the GUI
                Case $guimsg = $button1
                    button1()
    ; runs button1 function
                Case $guimsg = $button2
                    button2()
    ; runs button2 function
            EndSelect
        WEnd

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint