From 46a3cf2e1e225fcb39911942f42c6c929c3e02a0 Mon Sep 17 00:00:00 2001
From: "Adam D. Ruppe" <destructionator@gmail.com>
Date: Tue, 4 Feb 2014 19:04:53 -0500
Subject: [PATCH] more tab stuff

---
 minigui.d | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/minigui.d b/minigui.d
index 6847379..ad9091b 100644
--- a/minigui.d
+++ b/minigui.d
@@ -792,6 +792,15 @@ class Window : Widget {
 			},
 		);
 
+		bool skipNextChar = false;
+
+		addEventListener("char", (Widget, Event ev) {
+			if(skipNextChar) {
+				ev.preventDefault();
+				skipNextChar = false;
+			}
+		});
+
 
 		defaultEventHandlers["keydown"] = delegate void(Widget ignored, Event event) {
 			Widget _this = event.target;
@@ -822,8 +831,18 @@ class Window : Widget {
 
 				if(tabOrdering.length) {
 					bool seenThis = false;
+					Widget previous;
 					foreach(idx, child; tabOrdering) {
 						if(child is focusedWidget) {
+
+							if(event.shiftKey) {
+								if(idx == 0)
+									recipient = tabOrdering[$-1];
+								else
+									recipient = tabOrdering[idx - 1];
+								break;
+							}
+
 							seenThis = true;
 							if(idx + 1 == tabOrdering.length) {
 								// we're at the end, either move to the next group
@@ -836,17 +855,20 @@ class Window : Widget {
 							recipient = child;
 							break;
 						}
+						previous = child;
 					}
 				}
 
 				if(recipient !is null) {
-					import std.stdio; writeln(typeid(recipient));
+					// import std.stdio; writeln(typeid(recipient));
 					version(Windows) {
 						if(recipient.hwnd !is null)
 							SetFocus(recipient.hwnd);
 					} else {
 						focusedWidget = recipient;
 					}
+
+					skipNextChar = true;
 				}
 			}
 		};
@@ -890,6 +912,7 @@ class Window : Widget {
 			auto event = new Event(ev.pressed ? "keydown" : "keyup", focusedWidget);
 			event.character = ev.character;
 			event.key = ev.key;
+			event.shiftKey = (ev.modifierState & ModifierState.shift) ? true : false;
 			event.dispatch();
 		}
 		return super.dispatchKeyEvent(ev);
@@ -2188,6 +2211,8 @@ class Event {
 	Key key;
 	dchar character;
 
+	bool shiftKey;
+
 	private bool isBubbling;
 
 	/// this sends it only to the target. If you want propagation, use dispatch() instead.