public override void Create(VisualElement root) { var text = new TextField("Distance"); var placeholder = new Placeholder("Kilometers"); placeholder.AddToField(text); root.Add(text); }
private VisualElement CreateFooter() { var expressionText = new TextField { tooltip = "Type an expression to execute" }; expressionText.AddToClassList(UssExpressionClassName); void execute() { if (string.IsNullOrWhiteSpace(expressionText.text)) { var valid = ExecuteExpression(expressionText.text); if (valid) { expressionText.SetValueWithoutNotify(string.Empty); } EnableInClassList(UssExpressionInvalidClassName, !valid); } }; expressionText.RegisterCallback <KeyDownEvent>(evt => { if (evt.keyCode == KeyCode.KeypadEnter || evt.keyCode == KeyCode.Return) { execute(); } }); var executeButton = new IconButton(execute) { image = _executeIcon.Texture, tooltip = "Execute this expression" }; executeButton.AddToClassList(UssExecuteButtonClassName); var placeholder = new Placeholder("Execute Expression"); placeholder.AddToField(expressionText); var footer = new Toolbar(); footer.AddToClassList(UssFooterClassName); footer.Add(expressionText); footer.Add(executeButton); return(footer); }
private VisualElement CreateToolbar() { var watchField = new TextField { tooltip = "Type a VariableReference to watch" }; watchField.AddToClassList(UssWatchClassName); void watch() { if (string.IsNullOrWhiteSpace(watchField.text)) { var valid = AddWatch(watchField.text); if (valid) { watchField.SetValueWithoutNotify(string.Empty); } EnableInClassList(UssWatchInvalidClassName, !valid); } }; watchField.RegisterCallback <KeyDownEvent>(evt => { if (evt.keyCode == KeyCode.KeypadEnter || evt.keyCode == KeyCode.Return) { watch(); } }); var placeholder = new Placeholder("Add watch"); placeholder.AddToField(watchField); var watchButton = new IconButton(watch) { image = Icon.View.Texture, tooltip = "Watch this variable" }; watchButton.AddToClassList(UssWatchButtonClassName); var loggingButton = new Image { image = _logIcon.Texture, tooltip = "Enable/Disable logging of graph statistics" }; loggingButton.AddToClassList(UssLoggingClassName); loggingButton.AddManipulator(new Clickable(() => { CompositionManager.LogTracking = !CompositionManager.LogTracking; _logGraphEnabled.Value = CompositionManager.LogTracking; EnableInClassList(UssLoggingActiveClassName, CompositionManager.LogTracking); })); var toolbar = new Toolbar(); toolbar.AddToClassList(UssToolbarClassName); toolbar.Add(watchField); toolbar.Add(watchButton); toolbar.Add(loggingButton); return(toolbar); }