Skip to content

Conversation

@dnenov
Copy link
Collaborator

@dnenov dnenov commented Feb 20, 2025

Purpose

Addresses the following Jira issue - Enable Ctrl + C to copy selected data out of preview bubbles/watch nodes

The solution was not as straightforward as the text nodes to copy from were children of a TreeView element.

  • The successful solution was to integrate the key capture on the level of the TreeViewItem manipulation, which was already working to enable the up/down navigation.
  • Finally, since the TreeViewItem's KeyDown event handler did not correctly capture a Ctrl+Key combination outright, we had to listen for the combination and string it manually together.
  • To enable this workflow, a stop-watch routine was also implemented to reset the timer between Ctrl occurrences.
  • Added test coverage for the new functionality.

Carnac_peDt5J7cd0

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

  • enabled clipboard copy on Ctrl+C for info bubbles and watch nodes
  • added test coverage

Reviewers

@achintyabhat
@reddyashish
@zeusongit

FYIs

@QilongTang
@johnpierson

- enabled clipboard copy on Ctrl+C for info bubbles and watch nodes
- added test coverage
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-4361

@johnpierson
Copy link
Member

So far testing locally with copying various data and arrow key navigation, this looks pretty good to me.

private void treeviewItem_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (prevWatchViewModel != null)
if (prevWatchViewModel != null || Models.DynamoModel.IsTestMode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is prevWatchViewModel value null when in TestMode?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it shouldn't be null.

Copy link
Contributor

@zeusongit zeusongit Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then I am confused, why add the IsTestMode condition?

Copy link
Collaborator Author

@dnenov dnenov Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was null, yes. At least when reusing the design pattern of the existing watchnode/info-bubble tests. I didn't feel I should go out of my way to look into creating the view model, as this solution worked and I have used it (bypassing checks based on Dynamo.IsTestMode) in the past in similar circumstances.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests of this test suite passed locally as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnenov Thank you for the new changes, looks clean and better.

Is there any unit test present for this functionality? Which tests are being affected, causing the need for IsTestMode check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the IsTestMode , you are right! Apologies.

@johnpierson
Copy link
Member

Is this going to be in 3.5?

@zeusongit
Copy link
Contributor

Is this going to be in 3.5?

Yes

@zeusongit zeusongit added this to the 3.5 milestone Feb 20, 2025
this.Loaded += WatchTree_Loaded;
this.Unloaded += WatchTree_Unloaded;

_ctrlResetTimer.Tick += _ctrlResetTimer_Tick;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using this pattern inside the DynamoView (_workspaceResizeTimer.Tick += _resizeTimer_Tick;) without unsubscribing, I assumed this is safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unsubscribe to it? If possible? Probably add a Dispose method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. The Watchnode does not have a Dispose, but a similar thing is happening inside the Loaded/Unloaded handlers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeusongit I removed the timer altogether. Sporadic tests were failing, I don't know if that was due to a leak, but I was able to remove the timer while tinkering. Sadly, I cannot figure out a way to test for the Keyboard.Modifiers combination, as far as I can see it's impossible to set that programmatically. So I don't have a way of Unit testing that functionality. I don't know if we have a different framework for Integration tests that we use to simulate clicks and user interactions, but probably that would be the way to do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dnenov, I was iffy with the timer approach myself, so thanks for looking into it. I will ask if this is something AGT tests can cover.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely ^

- moved subscribe/unsubscribe from timer events inside the loaded/unloaded parts of the watchnode
@zeusongit
Copy link
Contributor

- tooltip text change for the color node was causing a test to fail, fixing that although it's not part of the scope of this PR
@dnenov
Copy link
Collaborator Author

dnenov commented Feb 23, 2025

@dnenov One failed test that looks new, Dynamo.Tests.SerializationTests.InPortDescriptionDeserilizationTest

I fixed the test, although it was not related to this PR. Now a different test is failing, which passes locally RemovesScriptTagsFromLoadedHtml:
image

Could it be that changes to the master are interfering? This PR should not be affecting these tests.

- now uses `Keyboard.Modifiers `  to detect Ctrl+C combination, which eliminates the need for a timer altogether
- no longer able to do a wpf test, I found it impossible to simulate the hardware keyboard.modifiers necessary for the test to run
@reddyashish
Copy link
Contributor

RemovesScriptTagsFromLoadedHtml has been flaky on CI jobs.


var nodeModelNode = this.CurrentDynamoModel.CurrentWorkspace.Nodes.Where(x => x.GUID == new Guid("c848cc3cb24a477f8248e53fc9304cc1")).First();
Assert.AreEqual(nodeModelNode.InPorts.First().ToolTip, "List of colors to include in the range");
Assert.AreEqual(nodeModelNode.InPorts.First().ToolTip, "List of colors to include in the range (disabled)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the expected fix here @dnenov , need to dig why and when was the tooltip changed. Also I think the expected and actual variables are inverted in the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks to me that this tooltip recently changed - I think it's on the Color node, or similar. And it's hard-coded inside the test, so that's the fix of it.

- remove unnecessary code
@zeusongit zeusongit merged commit a727eae into DynamoDS:master Feb 24, 2025
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants