Click or drag to resize

GuiWindowDragWindow Method

Makes the window movable. It's an improved version of the stock GUI.DragWindow() method.

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public static bool DragWindow(
	ref Rect windowRect,
	Rect dragArea
)
Request Example View Source

Parameters

windowRect
Type: Rect
The window rectangle. It must be the same instance which is passed to the GUILayout.Window method.
dragArea
Type: Rect
The rectangle in the local windows's space that defines the dragging area. In case of it's out of bounds of the window rectangle, it will be clipped.

Return Value

Type: Boolean
true if the window is being dragged.
Remarks
The main difference from the stock method is that the dragging state is not reset by the GUI layout methods. Also, it reports the draggign state, so some updates to the dialog may be frozen to not inerfere with the move operation.
Examples
public class GuiWindowDemo1 : MonoBehaviour {
  Rect windowRect;
  Rect titleBarRect = new Rect(0, 0, 10000, 20);

  void OnGUI() {
    windowRect = GUILayout.Window(12345, windowRect, WindowFunc, "Test title");
  }

  void WindowFunc(int windowId) {
    // ...add the controls....

    // Allow the window to be dragged by its title bar.
    GuiWindow.DragWindow(ref windowRect, titleBarRect);
  }
}
See Also