diff --git a/Code/App.cs b/Code/App.cs index d59a8a9..9d02572 100644 --- a/Code/App.cs +++ b/Code/App.cs @@ -104,6 +104,7 @@ public bool HasUnsavedChanges if(!_hasUnsavedChanges) { _mainView.SetNodesClean(); + _mainView.ClearScrollLock(); } } get => _hasUnsavedChanges; diff --git a/Code/NodeCode/MainView.cs b/Code/NodeCode/MainView.cs index ff1173b..e1c9912 100644 --- a/Code/NodeCode/MainView.cs +++ b/Code/NodeCode/MainView.cs @@ -99,6 +99,25 @@ public class MainView : ColorRect private App _app; public int CurrentParentIndex {set; get;} + + + public static bool ScrollLock + { + set + { + if(value) + { + _scrollLock++; + } + else + { + _scrollLock--; + } + } + get => _scrollLock != 0; + } + private static int _scrollLock = 0; + private Vector2 _scrollCurrent; public Color GridMajorColor { @@ -233,6 +252,7 @@ public override void _Ready() _graph.Connect( "paste_nodes_request", this, nameof(RequestPasteNode) ); _graph.Connect( "delete_nodes_request", this, nameof(RequestDeleteNode) ); _graph.Connect( "gui_input", this, nameof(GraphClick) ); + _graph.Connect( "scroll_offset_changed", this, nameof(GraphOnScroll) ); _tween = new Tween(); AddChild( _tween ); @@ -253,7 +273,6 @@ public override void _Ready() } catch( Exception e ) { - throw e; _app.CatchException( e ); } } @@ -421,7 +440,19 @@ private void OnSearch( string text ) CenterViewOnKeyedNode( text ); } - + + private void GraphOnScroll(Vector2 offset) + { + if(ScrollLock) + { + _graph.ScrollOffset = _scrollCurrent; + } + else + { + _scrollCurrent = offset; + } + } + private void GraphClick( InputEvent @event ) { if( @event is InputEventMouseButton eventMouse ) @@ -895,6 +926,11 @@ public void SetNodesClean() node.Dirty = false; } } + + public void ClearScrollLock() + { + _scrollLock = 0; + } #endregion #region Connections diff --git a/Code/NodeCode/NodeSlots/TextAreaRichSlot.cs b/Code/NodeCode/NodeSlots/TextAreaRichSlot.cs index e912c97..8877d6b 100644 --- a/Code/NodeCode/NodeSlots/TextAreaRichSlot.cs +++ b/Code/NodeCode/NodeSlots/TextAreaRichSlot.cs @@ -24,6 +24,8 @@ public override void _Ready() _display = this.GetNodeFromPath( _displayPath ); _field.Connect( "text_changed", this, nameof(OnTextChanged) ); + _field.Connect("mouse_entered",this,nameof(OnEnter)); + _field.Connect("mouse_exited",this,nameof(OnExit)); } public void Init(GenericDataDictionary template, GenericDataObject parentModel) @@ -63,5 +65,15 @@ private void OnTextChanged() _model.value = _field.Text; OnValueUpdated?.Invoke(); } + + private void OnEnter() + { + MainView.ScrollLock = true; + } + + private void OnExit() + { + MainView.ScrollLock = false; + } } } \ No newline at end of file diff --git a/Code/NodeCode/NodeSlots/TextAreaSlot.cs b/Code/NodeCode/NodeSlots/TextAreaSlot.cs index 9db6176..34e17a3 100644 --- a/Code/NodeCode/NodeSlots/TextAreaSlot.cs +++ b/Code/NodeCode/NodeSlots/TextAreaSlot.cs @@ -19,8 +19,11 @@ public override void _Ready() { _label = this.GetNodeFromPath