News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Drag Rectangles/ GUI Selection

Started by kevin, April 03, 2011, 10:03:09 PM

Previous topic - Next topic

kevin

 Drag Rectangles/ GUI Selection

   This example lets the user left click on any rectangle on screen and drag it around the screen bounds.  Most of the code is simply setting up the zones and little function interface mixed with the global input frame work (posted a few days ago).

  This selection works via modes,  the program starts in drag mode zero.  In this mode, the program is waiting for the user to click upon a zone.  When the mouse button is down, and the click point of impact occurs inside the 'closest' zone, the program remembers what zone was clicked, as well as the offset position from the click point (the handle) and then switches drag mode on.    When in drag mode, the input logic swaps to rather than worrying about if the user clicks on the zone, it now just waits for the user to release the mouse button.  When that occurs, the drag mode is reset to the mode Zero and the cycle begins again.   The dragging is done by simply position the dragged object at the current mouse position + offset when drag mode is on.  


Related Examples:

   * Drag Sprites
   * Re-sizable Rectangle
   * Toggle The  Mouse Pointer Off When It's Not Moving
   * Check If a point is inside a box/rect region (Manual PointInBox)
   * Storing User Input In Global Types
    * Action GUI




 Download Attached Bellow: