program HowToMoveAPanel; uses SwinGame,sgTypes,sgUserInterface; procedure Main(); var p : Panel; begin OpenGraphicsWindow('How To Move A Panel' ,800 ,600 ); LoadDefaultColors(); p := LoadPanel('panelwithlabel.txt' ); ShowPanel(p ); repeat ProcessEvents(); ClearScreen(ColorWhite ); DrawInterface(); PanelSetDraggable(p ,true ); GUISetBackgroundColor(ColorGreen ); UpdateInterface(); RefreshScreen(); until WindowCloseRequested(); ReleaseAllResources(); end; begin Main(); end.
How To Move A Panel
This article will demonstrate how to move a panel on screen using SwinGame’s User Interface.
In most programs you will want to move the component around the screen using the mouse. To do this it is required SwinGame’s User Interface functionality.
The function that enables the component to be able to move around the screen using a mouse is called PanelSetDraggable. This procedure allows the dragging of component around the screen using a mouse.
To allow more customization you can also set the background color of the component to a different color by calling the GuiSetBackGroundColor procedure.
Call UpdateInterface in the game loop to check for draggable, region clicked and updated the interface to the latest change.
To demonstrate the use of SwinGAme’s User Interface a video will be display on the right and below is the code of the program.
If there is a useful hint you will find it in a box like this
Suggested projects will appear here.