#include <QClipboard>
#include <QEvent>
#include <QMenu>
+#include <QContextMenuEvent>
#include <QVBoxLayout>
PyConsole_EditorBase *PyConsole_ConsoleBase::PyConsole_Interp_CreatorBase::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const
PyConsole_Interp_EnhCreatorBase crea;
defaultConstructor(interp,crea);
}
+
+/*!
+ \brief Event handler.
+
+ Handles context menu request event.
+
+ \param o object
+ \param e event
+ \return True if the event is processed and further processing should be stopped
+*/
+bool PyConsole_EnhConsoleBase::eventFilter( QObject* o, QEvent* e )
+{
+ if ( o == myEditor->viewport() && e->type() == QEvent::ContextMenu )
+ {
+ contextMenuRequest( (QContextMenuEvent*)e );
+ return true;
+ }
+ return QWidget::eventFilter( o, e );
+}
+
+void PyConsole_EnhConsoleBase::contextMenuRequest( QContextMenuEvent * e )
+{
+ QMenu *menu(new QMenu(this));
+ contextMenuPopup(menu);
+ menu->move(e->globalPos());
+ menu->show();
+}
public:
PyConsole_EnhConsoleBase( QWidget* parent, PyConsole_Interp* interp = 0 );
virtual ~PyConsole_EnhConsoleBase() {}
+ virtual bool eventFilter( QObject * o, QEvent * e );
+ virtual void contextMenuRequest( QContextMenuEvent * e ) ;
};
#endif // PYCONSOLE_CONSOLEBASE_H