Step 2 - Callback FunctionsWhen you create a GUI object you can declare a function which will be called whenever the user interacts with the object e.g. when ever a button is pressed, whenever somebody types in a text field or when the mouse is clicked in the canvas. This function is called a callback. Built-in CallbacksThere are a number of callback functions which are part of Gsharp. We call these built-in callbacks. Most of the callbacks used in the default Gsharp interface are built-in (a few have been written in GSL and can be edited). A full list of built-in functions can be found in Built-in Callbacks In our example we set the callback of our button to be GuiFileExit
GuiFileExit is a built-in callback which will popup up a dialog saying "Are you sure you want to exit?" and then exits. Try it now by selecting the Exit button from our example. We can use the built-in callbacks to quickly add powerful functionality to our application. Later we will add GuiFilePrintSetup and GuiFilePrint to our application. In a few lines we will have added support for printing. Now carry on to Step 3 - Writing your own callbacks |