GUI Docker

Revision as of 22:42, 5 January 2010 by SIMU-NOVA (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


The GUIDocker class (perhaps better called a "GUI Snapper") can be GLOM'ed on to a GUI Control to handle snapping to the screen edges while dragging the control around.

The class is GLOM'ed on to the control specified and then the dock thresholds must be set. The thresholds can be set as one universal value and then individually overriden for each screen edge.

The positioning of the control will take scale of the RootParent GUI Control into account. The positioning is also performed on the control's RootParent.

The GUIDocker Class

field type description
offset Class xy Stores the mouse pointer offset from 0,0 (the top left of the Root Parent control) in OnMouseDown to keep a true position while dragging.
universalDock Float The distance from all edges beyond which the control is snapped to that edge.
dockRight Float Optional override of the universalDock distance for the right edge of the screen.
dockLeft Float Optional override of the universalDock for the left edge threshold.
dockTop Float Optional override of the universalDock for the top edge of the screen.
dockBottom Float Optional override of the universalDock for the bottom edge of the screen.


var DragWindow = CreateNodeFromPrototype("movepanel") = true
// Glom the class
GlomClass("GUIDocker", DragWindow)
where DragWindow is kindof GUIDocker
  // Set the universal dock distance
  DragWindow.universalDock = 15.0
  // Optionally, override the universal dock distance
  DragWindow.dockTop = 30.0
  DragWindow.dockBottom = 5.0    
  // DragWindow.dockLeft = 9.0
  // DragWindow.dockRight = 15.0


The methods that the GUI Docker traps for, OnMouseDown, OnMouseDrag and OnMouseUp, MUST make use of args.handled = true and args.interrupt = true.

If there is other functionality required in those Mouse Events by the GUI Control that has had the GUIDocker class GLOM'ed onto it, so a little creativity may be required to handle those events.

There is currently no way to set default values on a GLOM'ed class, but when there are, the universal dock value will be a default.

Personal tools