GUI Docker

From HEWIKI
Jump to: navigation, search

Contents

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.

Example

var DragWindow = CreateNodeFromPrototype("movepanel")
DragWindow.build = 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
.

Notes

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
Namespaces
Variants
Actions
Navigation
Toolbox