Opened 13 years ago

Last modified 8 years ago

#1472 new defect

wxgui layer manager output pane breaks PRIMARY X selection

Reported by: marisn Owned by: grass-dev@…
Priority: normal Milestone: 6.4.6
Component: wxGUI Version: svn-trunk
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

Settings -> Region -> Display region. Select output with mouse. Choose some other application (i.e. Kate) and press middle mouse button -> nothing is pasted as output pane explicitly interferes with copy/paste X mechanism and is inconsistent with rest of desktop environment.

Attachments (2)

copyAndPaste.diff (3.7 KB ) - added by wenzeslaus 13 years ago.
copyAndPaste.2.diff (3.9 KB ) - added by wenzeslaus 13 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by martinl, 13 years ago

Go to

Settings -> Preferences -> General

and enable Automatically copy selected text to clipboard. Helps?

comment:2 by martinl, 13 years ago

Milestone: 6.4.3

comment:3 by marisn, 13 years ago

Seems to do. Still I would call it worst design decision. Requiring user to enable copy/paste mechanism is total insanity. WXGUI is only application I know with such strange option.

in reply to:  3 ; comment:4 by martinl, 13 years ago

Replying to marisn:

Seems to do. Still I would call it worst design decision. Requiring user to enable copy/paste mechanism is total insanity. WXGUI is only application I know with such strange option.

well it's globally disabled, because there are OSs which behaves differently, at least MS Windows. So it's not right to call it the "worst design decision";-) Maybe we could enable this option automatically on GNU/Linux and Mac OSX?

in reply to:  4 ; comment:5 by cmbarton, 13 years ago

Replying to martinl:

Replying to marisn:

Seems to do. Still I would call it worst design decision. Requiring user to enable copy/paste mechanism is total insanity. WXGUI is only application I know with such strange option.

well it's globally disabled, because there are OSs which behaves differently, at least MS Windows. So it's not right to call it the "worst design decision";-) Maybe we could enable this option automatically on GNU/Linux and Mac OSX?

What happens on Windows when this is enabled?

in reply to:  5 comment:6 by wenzeslaus, 13 years ago

I'm not sure now about MS Windows. But on X11 there are two clipboards (normal and primary/mouse selection). But current (my) implementation in wxGUI replaces contents of the normal clipboard and so it is disabled by default. However in wx it is possible to use this primary clipboard see http://www.wxpython.org/docs/api/wx.Clipboard-class.html#UsePrimarySelection but I don't know how to use it. I have tried this but SetData needs another type of argument and I didn't get through this (suggestions?):

clipboard = wx.TheClipboard
clipboard.UsePrimarySelection()
clipboard.SetData(self.GetSelectedText()) # self.Copy() copies to standard clipboard
clipboard.UsePrimarySelection(primary=False)

With something like this, there would be still need for platform specific code from the same reason as mentioned above. On MS Windows it would replace current clipboard content and it is not what MS Windows user expect, I think.

comment:7 by cmbarton, 13 years ago

The only place that I can find this called is in the new stats display option for analysis graphs and in menuform.py that formats the dialogs for all GRASS command modules. The command...

wx.TheClipboard.UsePrimarySelection(True)

is commented out in line #735. Enabling this has no effect one way or the other on my Mac. I don't know what it would do on other platforms. But in this case, copying is done via button and not selected text anyway.

The issue you are having with the output console is a different one. There is a method that turns copying on an off at line #642 in output.py (def SetCopyingOfSelectedText(self, copy):)

I'm not sure why anyone would want copying off by default. But perhaps there is a reason.

When copying is on, it calls the Copy method of wx.StyledTextCtrl. AFAICT, there is no option with stc.Copy() to use the primary or normal clipboard.

Michael

in reply to:  1 comment:8 by neteler, 13 years ago

Replying to martinl:

Go to

Settings -> Preferences -> General

and enable Automatically copy selected text to clipboard. Helps?

I tried, no change. Example: I load a raster map into the wxGUI, use the right mouse button -> metadata -> select something from the r.info output and when pasting, it pastes the raster map name rather than the selected metadata. It would be pretty cool to convince wx to behave "normally".

by wenzeslaus, 13 years ago

Attachment: copyAndPaste.diff added

by wenzeslaus, 13 years ago

Attachment: copyAndPaste.2.diff added

comment:9 by wenzeslaus, 13 years ago

Both copyAndPaste.diff and copyAndPaste.2.diff (.2. may be better) will copy selected text to PRIMARY SELECTION clipboard. However both will discards contents of normal clipboard. So again it is reason to have it in settings. I'm not sure how it works on MS Win or Mac. I found code which may solve this platform things, see this link. But it also discards normal clipboard (same as my code).

Here's the code:

text = self.GetSelectedText()
data = wx.TextDataObject(text)
clipboard = wx.TheClipboard
clipboard.UsePrimarySelection()
        
if clipboard.IsOpened() or clipboard.Open():
     clipboard.SetData(data)
     clipboard.Close()
        
clipboard.UsePrimarySelection(False)

Maybe it could copy text to both clipboards. Replacing is better then discarding.

comment:10 by cmbarton, 13 years ago

This would work if we were binding copy and past to a button. That that is not what is happening. It is allowing copy/past within the window of a StyledTextCtrl. This is a special text control that allows for text-processor like functions, including copy/paste. You cannot use the clipboard code in this context.

Michael

comment:11 by neteler, 12 years ago

See also ticket #988

comment:12 by neteler, 8 years ago

Milestone: 6.4.36.4.6
Note: See TracTickets for help on using tickets.