void OnGUI() { // hook to this window if (webView.Hook(this)) { // do the first thing to do webView.LoadHTML(Compose()); } var half = new Rect(0, 0, position.width / 2, position.height); // html text field EditorGUI.BeginChangeCheck(); data = EditorGUI.TextArea(half, data); if (EditorGUI.EndChangeCheck()) { // push changes to webView and notify our input hook.Update(); webView.ExecuteJavascript("update()"); } half.x += half.width; if (Event.current.type == EventType.Repaint) { // keep the browser aware with resize webView.OnGUI(half); } else if (half.Contains(Event.current.mousePosition)) { GUIUtility.keyboardControl = 0; } }
private void OnGUI() { var ev = Event.current; // hook to this window if (_webView.Hook(this)) // do the first thing to do _webView.LoadURL("https://web-planner.herokuapp.com/"); if (ev.type == EventType.Repaint) { // keep the browser aware with resize _webView.OnGUI(new Rect(Vector2.zero, this.position.size)); } }
void OnGUI() { // hook to this window if (webView.Hook(this)) { // do the first thing to do webView.LoadHTML(Compose()); } var half = position.width / 2; // head/body/css/js var rect = new Rect(0, 0, (half - 50) / 4, 30); EditorGUI.BeginChangeCheck(); for (int i = 0; i < 4; i++) { if (GUI.Toggle(rect, i == panel, Styles.heads[i], Styles.headStyles[i])) { panel = i; } rect.x += rect.width; } if (GUI.Button(new Rect(half - 45, 0, 45, 30), "Copy")) { GUIUtility.systemCopyBuffer = Compose().Replace("\n", Environment.NewLine); } if (EditorGUI.EndChangeCheck()) { // need this so text field can be updated GUIUtility.keyboardControl = -1; } // html text field EditorGUI.BeginChangeCheck(); this[panel] = EditorGUI.TextArea(new Rect(0, 30, half, position.height - 30), this[panel], Styles.textArea); if (EditorGUI.EndChangeCheck()) { webView.LoadHTML(Compose()); } if (Event.current.type == EventType.Repaint) { // keep the browser aware with resize webView.OnGUI(new Rect(half, 0, half, position.height)); } }
void OnGUI() { if (webView.Hook(this)) { webView.LoadURL(url); } if (GUI.Button(new Rect(0, 0, 25, 20), "←")) { webView.Back(); } if (GUI.Button(new Rect(25, 0, 25, 20), "〒")) { url = "https://google.com"; webView.LoadURL(url); } if (GUI.Button(new Rect(50, 0, 25, 20), "→")) { webView.Forward(); } GUI.SetNextControlName("urlfield"); url = GUI.TextField(new Rect(75, 0, (position.width / 3) * 2, 20), url); var ev = Event.current; if (GUI.Button(new Rect(position.width - 75, 0, 75, 20), "Youtube")) { url = "https://www.youtube.com/"; webView.LoadURL(url); } if (ev.isKey && GUI.GetNameOfFocusedControl().Equals("urlfield")) { if (ev.keyCode == KeyCode.Return) { webView.LoadURL(url); GUIUtility.keyboardControl = 0; webView.SetApplicationFocus(true); ev.Use(); } } if (ev.type == EventType.Repaint) { webView.OnGUI(new Rect(0, 20, position.width, position.height - 20)); } }
void OnGUI() { // hook to this window if (webView.Hook(this)) { // do the first thing to do webView.LoadURL(url); } // Navigation if (GUI.Button(new Rect(0, 0, 25, 20), "←")) { webView.Back(); } if (GUI.Button(new Rect(25, 0, 25, 20), "→")) { webView.Forward(); } // URL text field GUI.SetNextControlName("urlfield"); url = GUI.TextField(new Rect(50, 0, position.width - 50, 20), url); var ev = Event.current; // Focus on web view if return is pressed in URL field if (ev.isKey && GUI.GetNameOfFocusedControl().Equals("urlfield")) { if (ev.keyCode == KeyCode.Return) { webView.LoadURL(url); GUIUtility.keyboardControl = 0; webView.SetApplicationFocus(true); ev.Use(); } } // else if (ev.keyCode == KeyCode.A && (ev.control | ev.command)) if (ev.type == EventType.Repaint) { // keep the browser aware with resize webView.OnGUI(new Rect(0, 20, position.width, position.height - 20)); } }
private void OnGUI() { #if DEV_MODE if (Event.current.type == EventType.KeyDown) { Debug.Log(StringUtils.ToString(Event.current)); } if (Event.current.type == EventType.MouseDown) { Debug.Log(StringUtils.ToString(Event.current)); } #endif DrawSideBar(sideBarRect); if (webView.Hook(this) || reload) { reload = false; webView.LoadURL(url); GUI.changed = true; Repaint(); } switch (Event.current.type) { case EventType.KeyDown: if (this == focusedWindow) { switch (Event.current.keyCode) { case KeyCode.Escape: Close(); break; case KeyCode.F5: webView.Reload(); break; case KeyCode.UpArrow: SetActiveView(activeView - 1); break; case KeyCode.DownArrow: SetActiveView(activeView + 1); break; case KeyCode.Home: SetActiveView(0); break; case KeyCode.End: SetActiveView(Urls.Length - 1); break; case KeyCode.PageUp: SetActiveView(activeView - 10); break; case KeyCode.PageDown: SetActiveView(activeView + 10); break; } } break; case EventType.Repaint: webView.OnGUI(new Rect(sideBarWidth, -yOffset, 1002f, position.height + yOffset)); break; } }