mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
ADDED: RMB > Copy item for HTML_WINDOW.
(Used at least in Footprint and Symbol Chooser details panes.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/17904
This commit is contained in:
parent
b9ebd3304b
commit
02a08bf9b1
@ -2,7 +2,7 @@
|
|||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
||||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
|
* Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@ -22,8 +22,11 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <widgets/html_window.h>
|
#include <wx/menu.h>
|
||||||
|
#include <wx/clipbrd.h>
|
||||||
|
#include <wx/log.h>
|
||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
|
#include <widgets/html_window.h>
|
||||||
|
|
||||||
|
|
||||||
HTML_WINDOW::HTML_WINDOW( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos,
|
HTML_WINDOW::HTML_WINDOW( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos,
|
||||||
@ -32,6 +35,15 @@ HTML_WINDOW::HTML_WINDOW( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos
|
|||||||
{
|
{
|
||||||
Bind( wxEVT_SYS_COLOUR_CHANGED,
|
Bind( wxEVT_SYS_COLOUR_CHANGED,
|
||||||
wxSysColourChangedEventHandler( HTML_WINDOW::onThemeChanged ), this );
|
wxSysColourChangedEventHandler( HTML_WINDOW::onThemeChanged ), this );
|
||||||
|
|
||||||
|
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( HTML_WINDOW::onRightClick ), nullptr, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HTML_WINDOW::~HTML_WINDOW()
|
||||||
|
{
|
||||||
|
// Disconnect Events
|
||||||
|
Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( HTML_WINDOW::onRightClick ), nullptr, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -70,3 +82,32 @@ void HTML_WINDOW::onThemeChanged( wxSysColourChangedEvent &aEvent )
|
|||||||
{
|
{
|
||||||
ThemeChanged();
|
ThemeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HTML_WINDOW::onRightClick( wxMouseEvent& event )
|
||||||
|
{
|
||||||
|
wxMenu popup;
|
||||||
|
popup.Append( wxID_COPY, "Copy" );
|
||||||
|
PopupMenu( &popup );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HTML_WINDOW::onMenuEvent( wxMenuEvent& event )
|
||||||
|
{
|
||||||
|
if( event.GetId() == wxID_COPY )
|
||||||
|
{
|
||||||
|
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
||||||
|
|
||||||
|
if( wxTheClipboard->Open() )
|
||||||
|
{
|
||||||
|
bool primarySelection = wxTheClipboard->IsUsingPrimarySelection();
|
||||||
|
wxTheClipboard->UsePrimarySelection( false ); // required to use the main clipboard
|
||||||
|
wxTheClipboard->SetData( new wxTextDataObject( SelectionToText() ) );
|
||||||
|
wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
|
||||||
|
wxTheClipboard->Close();
|
||||||
|
wxTheClipboard->UsePrimarySelection( primarySelection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
||||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
|
* Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@ -33,9 +33,11 @@
|
|||||||
class HTML_WINDOW : public wxHtmlWindow
|
class HTML_WINDOW : public wxHtmlWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HTML_WINDOW( wxWindow* aParent, wxWindowID aId=wxID_ANY, const wxPoint& aPos=wxDefaultPosition,
|
HTML_WINDOW( wxWindow* aParent, wxWindowID aId = wxID_ANY,
|
||||||
const wxSize& aSize=wxDefaultSize, long aStyle=wxHW_DEFAULT_STYLE,
|
const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize,
|
||||||
const wxString& aName="htmlWindow" );
|
long aStyle = wxHW_DEFAULT_STYLE, const wxString& aName = wxT( "htmlWindow" ) );
|
||||||
|
|
||||||
|
~HTML_WINDOW();
|
||||||
|
|
||||||
bool SetPage( const wxString& aSource ) override;
|
bool SetPage( const wxString& aSource ) override;
|
||||||
bool AppendToPage( const wxString& aSource );
|
bool AppendToPage( const wxString& aSource );
|
||||||
@ -47,6 +49,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void onThemeChanged( wxSysColourChangedEvent& aEvent );
|
void onThemeChanged( wxSysColourChangedEvent& aEvent );
|
||||||
|
void onRightClick( wxMouseEvent& event );
|
||||||
|
void onMenuEvent( wxMenuEvent& event );
|
||||||
|
|
||||||
wxString m_pageSource;
|
wxString m_pageSource;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user