ConsoleGuiTools icon indicating copy to clipboard operation
ConsoleGuiTools copied to clipboard

Copy Paste not supported from selected records in gridview output window

Open alienBear opened this issue 6 years ago • 3 comments
trafficstars

In original out-GridView output window, records could be selected and then copied to the clipboard to paste into emails or spreadsheets. This no longer appears to be possible under the current implementation. This issue is similar to issue #23 .

WorkAround Available: I found I could accomplish what I needed in the short term with the following, but the output window is dismissed, so multiple subsequent selections are not possible from the same output window.

... | Out-GridView -PassThru | convertTo-HTML | clip.exe

alienBear avatar Aug 19 '19 14:08 alienBear

🤔 I thought maybe this would be easy, but apparently it isn't...

https://github.com/PowerShell/GraphicalTools/blob/master/src/OutGridView.Gui/Views/DataGridView.xaml#L23 would seem to indicate there's a copy mode. Setting it to ExcludeHeader as per the docs results in an exception when you try to copy:

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The value "15" is not of type "OutGridView.Models.IValue" and cannot be used in this generic collection. (Parameter 'value')
   at System.Collections.Generic.Dictionary`2.System.Collections.IDictionary.set_Item(Object key, Object value)
   at Avalonia.Markup.Parsers.Nodes.StringIndexerNode.SetTargetValueCore(Object value, BindingPriority priority)           at Avalonia.Data.Core.BindingExpression.OnNext(Object value)
   at Avalonia.Reactive.AvaloniaPropertyObservable`1.Subscribed(IObserver`1 observer, Boolean first)
   at Avalonia.Reactive.LightweightObservableBase`1.Subscribe(IObserver`1 observer)
   at Avalonia.Data.BindingOperations.Apply(IAvaloniaObject target, AvaloniaProperty property, InstancedBinding binding, Object anchor)
   at Avalonia.AvaloniaObjectExtensions.Bind(IAvaloniaObject target, AvaloniaProperty property, IBinding binding, Object anchor)
   at Avalonia.Controls.DataGridColumn.GetCellValue(Object item, IBinding binding)
   at Avalonia.Controls.DataGrid.ProcessCopyKey(InputModifiers modifiers)
   at Avalonia.Controls.DataGrid.ProcessDataGridKey(KeyEventArgs e)
   at Avalonia.Controls.DataGrid.DataGrid_KeyDown(Object sender, KeyEventArgs e)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   at Avalonia.Input.KeyboardDevice.ProcessRawEvent(RawInputEventArgs e)
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Application.Run(CancellationToken token)
   at OutGridView.Application.AvaloniaAppRunner.AppMain(Application app) in C:\code\GraphicalTools\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 62
   at OutGridView.Application.AvaloniaAppRunner.RunApp(ApplicationData applicationData) in C:\code\GraphicalTools\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 44
   at OutGridView.Application.Program.Main(String[] args) in C:\code\GraphicalTools\src\OutGridView.Gui\Program.cs:line 32

Noting that the value changes based on which line you try to copy, we might need to add a handler or something for it.

corbob avatar Oct 02 '19 12:10 corbob

@corbob do you think we could get an issue going on Avalonia for this?

TylerLeonhardt avatar Oct 02 '19 23:10 TylerLeonhardt

@TylerLeonhardt I don't think an issue is happening with Avalonia, everything that I'm seeing indicates that even with WPF you need to create your own Copy handler, I just can't seem to get it to work (hence the question in discord about attaching a debugger). I'll spend some time on Monday trying to get a copy handler.

corbob avatar Oct 03 '19 05:10 corbob

No longer relevant as we're focusing on console gui tools only

SteveL-MSFT avatar Jul 26 '23 22:07 SteveL-MSFT