#1472: wxgui layer manager output pane breaks PRIMARY X selection
-------------------------+--------------------------------------------------
Reporter: marisn | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Keywords: | Platform: Unspecified
Cpu: Unspecified |
-------------------------+--------------------------------------------------
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.
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.
Replying to [comment:3 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?
Replying to [comment:4 martinl]:
> Replying to [comment:3 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?
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.
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.
Replying to [comment:1 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".
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 [http://www.java2s.com/Open-
Source/Python/GUI/wxPython/wxPython-
src-2.8.11.0/wxPython/wx/tools/Editra/src/util.py.htm 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.
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.